package com.gjintel.business.proj.controller;

import com.gjintel.business.proj.model.*;
import com.gjintel.business.proj.service.IProfessorService;
import com.gjintel.business.proj.service.IProjectBidService;
import com.gjintel.business.proj.service.IProjectInfoService;
import com.gjintel.business.proj.service.IProjectPauseService;
import com.gjintel.business.proj.service.impl.NotifyServiceImpl;
import com.gjintel.business.webcontent.model.WebContent;
import com.gjintel.business.webcontent.service.IWebContentService;
import com.gjintel.framework.common.service.IDepositExecuteService;
import com.gjintel.framework.common.service.IDepositService;
import com.gjintel.framework.constant.ActivitiMap;
import com.gjintel.framework.constant.Constant;
import com.gjintel.framework.constant.ProjectStatus;
import com.gjintel.framework.dataset.model.DataSet;
import com.gjintel.framework.dataset.service.IDataSetService;
import com.gjintel.framework.dict.model.Dictionary;
import com.gjintel.framework.holidayset.service.IHolidaySetService;
import com.gjintel.framework.log.model.LogInfo;
import com.gjintel.framework.log.util.LogUtil;
import com.gjintel.framework.log.util.LogUtil.LogType;
import com.gjintel.framework.projecttype.model.ProjectType;
import com.gjintel.framework.projecttype.service.IProjectTypeService;
import com.gjintel.framework.register.model.RegisterUser;
import com.gjintel.framework.register.service.IRegisterUserService;
import com.gjintel.framework.res.model.Resources;
import com.gjintel.framework.role.model.ProjectOperation;
import com.gjintel.framework.role.model.Role;
import com.gjintel.framework.role.service.IRoleService;
import com.gjintel.framework.user.model.User;
import com.gjintel.framework.user.model.UserRole;
import com.gjintel.framework.user.service.IUserService;
import com.gjintel.framework.util.CommUtil;
import com.gjintel.framework.util.DictUtil;
import com.gjintel.framework.util.FileResUtil;
import com.gjintel.framework.util.dto.Bank;
import com.gjintel.sdk.base.dao.Page;
import com.gjintel.sdk.base.dao.Sort;
import com.gjintel.sdk.util.DateUtils;
import com.gjintel.sdk.util.StringUtil;
import com.gjintel.sdk.util.WordHandler;
import com.gjintel.workflow.trade.dto.ProcessInstanceAndHistoryDto;
import com.gjintel.workflow.trade.service.IWorkflowProcessInstanceService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.activiti.engine.task.Comment;
import org.activiti.engine.task.Task;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 采购项目Controller
 *
 * @author xuyefei
 */
@RequestMapping("/business/projectmanage")
@Controller
@SuppressWarnings("unchecked")
public class ProjectController {

    @SuppressWarnings("unused")
    private static final Logger LOG = Logger.getLogger(ProjectController.class);

    @Autowired
    private IUserService userService;

    @Autowired
    private IProjectInfoService projectInfoService;

    @Autowired
    private IWorkflowProcessInstanceService workflowProcessInstanceService;

    @Autowired
    private IProjectTypeService projectTypeService;

    @Autowired
    private IRoleService roleService;

    @Autowired
    private IDataSetService dataSetService;

    @Autowired
    private IProfessorService professorService;

    @Autowired
    private IRegisterUserService registerUserService;

    @Autowired
    private IDepositService depositService;

    @Autowired
    private IProjectPauseService profectPauseService;

    @Autowired
    private IWebContentService webContentService;

    @Autowired
    private IProjectBidService projectBidService;

    // 流程key
    private static final String PROCESS_DEFINATION_KEY = "tender";

    @Autowired
    private NotifyServiceImpl notifyService;


    /**
     * 上传的合同资源文件
     */
    private Integer UPLOADCONTRACT_RES = 7;

    /**
     * 验收报告资源文件
     */
    private Integer AUDITREPORT_RES = 20;

    /**
     * 专家劳务支出资源文件
     */
    private Integer EXPERTSERVICE_RES = 10;

    /**
     * 评审纪要
     */
    private Integer REVIEWSUMMARY_RES = 11;

    /**
     * 初审表
     */
    private Integer FIRSTTRIAL_RES = 12;

    /**
     * 签到表
     */
    private Integer SIGNIN_RES = 13;

    /**
     * 询标函
     */
    private Integer TENDER_RES = 14;

    /**
     * 投标文件签收表
     */
    private Integer bidSIGNIN_RES = 15;

    @Autowired
    private IHolidaySetService holidaySetService;

    @Autowired
    private IDepositExecuteService depositExecuteService;

    /**
     * 采购人项目列表
     *
     * @param session
     * @return
     */
    @RequestMapping("/index")
    public ModelAndView index(HttpSession session) {
        ModelAndView mv = new ModelAndView("/proj/project");
        User user = (User) session.getAttribute("loginUser");
        // 获取项目类型
        List<ProjectType> projectTypeList = projectTypeService.findAll();
        mv.addObject("projectTypeList", projectTypeList);

        // 判断是否为采购人，显示创建按钮
        String roleIds = ActivitiMap.BUYER_ID;
        boolean isShowCreateButton = roleService.isPrivilege(user.getId(), roleIds);
        mv.addObject("isShowCreateButton", isShowCreateButton);
        return mv;
    }

    /**
     * 项目审核列表
     *
     * @param session
     * @return
     */
    @RequestMapping("/audit/audit")
    public ModelAndView audit(HttpSession session) {
        ModelAndView mv = new ModelAndView("/proj/audit/projects-approve");
        // 获取项目类型
        List<ProjectType> projectTypeList = projectTypeService.findAll();
        mv.addObject("projectTypeList", projectTypeList);
        return mv;
    }

    /**
     * 项目分配列表
     *
     * @param session
     * @return
     */
    @RequestMapping("/assign/assign")
    public ModelAndView assign(HttpSession session) {
        ModelAndView mv = new ModelAndView("/proj/assign/alert-management");
        // 获取项目类型
        List<ProjectType> projectTypeList = projectTypeService.findAll();
        mv.addObject("projectTypeList", projectTypeList);
        return mv;
    }

    /**
     * 投标项目列表
     *
     * @param session
     * @return
     */
    @RequestMapping("/bidder/shot")
    public ModelAndView shot(HttpSession session) {
        ModelAndView mv = new ModelAndView("/proj/bidder/project-shot");
        // 获取项目类型
        List<ProjectType> projectTypeList = projectTypeService.findAll();
        mv.addObject("projectTypeList", projectTypeList);
        return mv;
    }

    /**
     * 业务管理员列表
     *
     * @param session
     * @return
     */
    @RequestMapping("/bizmanager/projectBiz")
    public ModelAndView projectBiz(HttpSession session) {
        ModelAndView mv = new ModelAndView("/proj/bizmanager/project-biz");
        // 获取项目类型
        List<ProjectType> projectTypeList = projectTypeService.findAll();
        mv.addObject("projectTypeList", projectTypeList);
        return mv;
    }

    /**
     * 系统管理员列表
     *
     * @param session
     * @return
     */
    @RequestMapping("/bizmanager/projectSys")
    public ModelAndView projectSys(HttpSession session) {
        ModelAndView mv = new ModelAndView("/proj/sysmanager/project");
        // 获取项目类型
        List<ProjectType> projectTypeList = projectTypeService.findAll();
        User user = (User) session.getAttribute("loginUser");

        mv.addObject("user", user);
        mv.addObject("sessionId", session.getId());
        mv.addObject("projectTypeList", projectTypeList);
        return mv;
    }

    /**
     * 监督员列表
     *
     * @param session
     * @return
     */
    @RequestMapping("/supervisor/projectSup")
    public ModelAndView projectSup(HttpSession session) {
        ModelAndView mv = new ModelAndView("/proj/supervisor/project");
        // 获取项目类型
        List<ProjectType> projectTypeList = projectTypeService.findAll();
        mv.addObject("projectTypeList", projectTypeList);
        return mv;
    }

    /**
     * 项目编制列表
     *
     * @return
     */
    @RequestMapping("/leader/compile")
    public ModelAndView compile() {
        ModelAndView mv = new ModelAndView("/proj/leader/project");
        // 获取项目类型
        List<ProjectType> projectTypeList = projectTypeService.findAll();
        mv.addObject("projectTypeList", projectTypeList);
        return mv;
    }


    /**
     * @param
     * @return
     * @description财务管理员列表
     */
    @RequestMapping("/finance/financeList")
    public ModelAndView finance(HttpSession session) {
        List<Dictionary> depostFilter = DictUtil.dictChildren("depositFilter");
        ModelAndView mv = new ModelAndView("/proj/finance/project");
        mv.addObject("depostFilter", depostFilter);
        return mv;
    }


    /**
     * @param session
     * @param project
     * @param page
     * @param sort
     * @param startTime   创建开始时间
     * @param stopTime    创建结束时间
     *                    开标开始时间
     * @param bidStopTime 开标结束时间
     * @return
     * @description 项目列表
     * @author wei
     * @date 2016-8-16
     */
    @RequestMapping("/list")
    @ResponseBody
    public JSONObject list(HttpSession session, ProjectInfo project, Page page, Sort sort, java.sql.Date startTime,
                           java.sql.Date stopTime, java.sql.Date bidTime, java.sql.Date bidStopTime, String roleId) {
        long sTime = System.currentTimeMillis(); // 获取开始时间
        long eTime = 0;
        User user = (User) session.getAttribute("loginUser");
        // 结束时间处理，加一天
        stopTime = StringUtil.addOneDayDate(stopTime, 1);
        bidStopTime = StringUtil.addOneDayDate(bidStopTime, 1);
        String _processIds = "";
        String _filter = null;
        //增加保证金筛选
        if (project.getExecutePromissFilter() != null && project.getExecutePromissFilter().equals(Constant.UNPAY_EXECUTE_UNRETURN)) {
            //未交履约保证金未退
            project.setReturnDepositFlag(false);
            project.setStatusExecutePromiss(0);

        } else if (project.getExecutePromissFilter() != null && project.getExecutePromissFilter().equals(Constant.PAY_EXECUTE_UNRETURN)) {
            //已交履约保证金未退
            project.setReturnDepositFlag(false);
            project.setStatusExecutePromiss(1);
        } else if (project.getExecutePromissFilter() != null && project.getExecutePromissFilter().equals(Constant.PAY_EXECUTE_RETURN)) {
            //已交履约保证金已退
            project.setReturnDepositFlag(true);
            project.setStatusExecutePromiss(1);
        } else if (project.getExecutePromissFilter() != null && project.getExecutePromissFilter().equals(Constant.ALL_DEPOSIT_RETURN)) {
            //履约保证金已退(全退)
            project.setReturnDepositFlag(true);
            project.setStatusExecutePromiss(2);
        }


        // 增加流程id的过滤：如果角色不是指定的“超级管理员，业务管理员、监督员、系统管理员“等 ，则取出processId过滤.
        // TODO:数据量较大时要考虑性能问题（可考虑增加时间过滤)
        if (!"bizmanager".equals(roleId)// 业务管理员页面
                && !"administrator".equals(roleId)// 系统管理员页面
                && !"supervisor".equals(roleId)// 监督员页面
                && !"finance".equals(roleId)) {//财务管理员页面

            List<ProcessInstanceAndHistoryDto> processInstanceList = workflowProcessInstanceService
                    .findProcessInstanceAndHistoryList(PROCESS_DEFINATION_KEY, user.getId(), roleId);
            eTime = System.currentTimeMillis(); // 获取结束时间
            for (ProcessInstanceAndHistoryDto dto : processInstanceList) {
                _processIds += "'" + dto.getBusinessKey() + "',";
            }
            if (_processIds.length() > 0) {
                _processIds = _processIds.substring(0, _processIds.length() - 1);
            }
            _filter = _processIds;
        }

        //数据填充到page
        project.setAuditable(null);
        this.projectInfoService.findAllByIds(_filter, project, page, sort, startTime, stopTime, bidTime, bidStopTime,
                null, null);

        // 获取用户所以角色ids
        String roleIds = "";
        List<Role> roleList = roleService.findRolesByUserId(user.getId());
        for (Role role : roleList) {
            roleIds += "'" + role.getId() + "',";
        }
        if (roleIds.length() > 0) {
            roleIds = roleIds.substring(0, roleIds.length() - 1);
        }

        List<ProjectInfo> pageList = page.getResult();
        for (ProjectInfo pro : pageList) {
            Dictionary dicProStatus = DictUtil.dict("proj_status", pro.getStatus() + "");
            if (dicProStatus != null) {
                pro.setStatusName(dicProStatus.getName());// 项目状态
            } else {
                pro.setStatusName("未知");// 项目状态
            }

            //************************** BEGIN: 取出操作菜单列表，循环组合为html
            StringBuffer _sbOpera = new StringBuffer("");
            List<ProjectOperation> list = roleService.findOperationByRoleIdAndStatus(roleIds, pro.getStatus() + "", PROCESS_DEFINATION_KEY);// 数据库中取
            // 缓存中取
            // List<ProjectOperation> list =
            // InitCacheData.getInstance().getCacheOperationData(CacheType.PROJ_OPERATION).get(ActivitiMap.getProperty(roleId)).get(pro.getStatus()+"");
            int opCount = 1;//操作菜单的数量
            for (ProjectOperation op : list) {
                if (op.getRoleId().equals(ActivitiMap.getProperty(roleId))) {
                    if (op.getOperaName().equals("退还保证金")) {
                        if (pro.getReturnDepositFlag() != true) {
                            _sbOpera.append(op.getActionUrl().replace("row.id", pro.getId()) + (opCount % 3 == 0 ? "<br/>" : ""));
                        }
                    } else if (op.getOperaName().equals("退还履约保证金")) {
                        boolean showReturnFlag = this.excuteDepositButtionByProjectStatus(pro.getStatus());
                        if (pro.getFinishExecuteDesposit() != 1 && showReturnFlag == true) {
                            _sbOpera.append(op.getActionUrl().replace("row.id", pro.getId()) + (opCount % 3 == 0 ? "<br/>" : ""));
                        }
                    } else if (op.getId().equals(Constant.BIDDING_PAUSE_BUTTON)) {//竞价公示暂停
                        List<ProjectPause> pauselist = profectPauseService.getWorkingProjectPause(Constant.BIDDING_PAUSE, pro.getId());
                        if (pauselist.size() < 1) {
                            _sbOpera.append(op.getActionUrl().replace("row.id", pro.getId()) + (opCount % 3 == 0 ? "<br/>" : ""));
                        } else if (pauselist.get(0).getResult().equals("2") || pauselist.get(0).getResult().equals("3")) {
                            _sbOpera.append(op.getActionUrl().replace("row.id", pro.getId()) + (opCount % 3 == 0 ? "<br/>" : ""));
                        }
                    } else if (op.getId().equals(Constant.WIN_BIDDING_SHOW_PAUSE_BUTTON)) {//中标公示暂停
                        List<ProjectPause> pauselist = profectPauseService.getWorkingProjectPause(Constant.WIN_BIDDING_SHOW_PAUSE, pro.getId());
                        if (pauselist.size() < 1) {
                            _sbOpera.append(op.getActionUrl().replace("row.id", pro.getId()) + (opCount % 3 == 0 ? "<br/>" : ""));
                        } else if (pauselist.get(0).getResult().equals("2") || pauselist.get(0).getResult().equals("3")) {
                            _sbOpera.append(op.getActionUrl().replace("row.id", pro.getId()) + (opCount % 3 == 0 ? "<br/>" : ""));
                        }

                    } else {
                        _sbOpera.append(op.getActionUrl().replace("row.id", pro.getId()) + (opCount % 3 == 0 ? "<br/>" : ""));
                    }
                    opCount++;
                }
            }//************************** END: 取出操作菜单列表，循环组合为html

            if ("bizmanager".equals(roleId)) {// 列表页面是业务管理员列表页面时
                // 终止
                UserRole ur = roleService.findUserRole(ActivitiMap.BIZMANAGER_ID, user.getId());
                if (ur != null && pro.getStatus() != Integer.valueOf(ProjectStatus.CANCEL.toString())// 撤销
                        // 不显示终止操作菜单
                        && pro.getStatus() != Integer.valueOf(ProjectStatus.PROJ_OVER.toString())// 结项
                        // 不显示终止操作菜单
                        && pro.getStatus() != Integer.valueOf(ProjectStatus.FLOW_DOWN.toString())// 流标
                        // 不显示终止操作菜单
                        && pro.getStatus() != Integer.valueOf(ProjectStatus.SHOWING_FLOW.toString())) {// 流标公示
                    // 不显示终止操作菜单
                    _sbOpera.append(Constant.CANCLE_PROJECT.replace("row.id", pro.getId()));
                }

                //添加 查看资料 操作(任何状态下)
                _sbOpera.append(Constant.VIEWFILE_OPERATION.replace("row.id", pro.getId()));
            }

            if ("administrator".equals(roleId)) {// 列表页面是系统管理员列表页面时
                // 系统管理员
                UserRole adminUr = roleService.findUserRole(ActivitiMap.ADMINISTRATOR_ID, user.getId());
                if (adminUr != null && isCodeEdit(pro.getStatus())) {
                    // 添加变更项目编号
                    _sbOpera.append(Constant.EDITPROJECTCODE_OPERATION.replace("row.id", pro.getId()));
                }
            }

            if ("supervisor".equals(roleId)) {// 列表页面是监督员列表页面时
                // 监督员
                UserRole adminUr = roleService.findUserRole(ActivitiMap.SUPERVISOR_ID, user.getId());
            }

            // 添加项目详情操作
            _sbOpera.append(Constant.DETAILS_OPERATION.replace("row.id", pro.getId()));
            pro.setOperation(_sbOpera.toString());
        }

        // long eTime=System.currentTimeMillis(); //获取结束时间

        System.err.println("++++++++++++++++++++++++ 耗时： " + (eTime - sTime));

        return CommUtil.getPageJSONData(page, true);
    }

    /**
     * @description 是否在分配阶段之后，采购人确认之前
     * @author wwang
     * @date 2016年9月18日
     */
    private boolean isCodeEdit(Integer status) {
        List<Integer> list = new ArrayList<Integer>();
//		list.addAll(Arrays.asList(Integer.valueOf(ProjectStatus.WAIT_SUBMIT.toString()),
//				Integer.valueOf(ProjectStatus.WAIT_AUDIT.toString())//
//				, Integer.valueOf(ProjectStatus.AUDIT_NOT_PASS.toString()),
//				Integer.valueOf(ProjectStatus.WAIT_APPLY.toString())));
        list.addAll(Arrays.asList(Integer.valueOf(ProjectStatus.WAIT_COMPILE.toString()),
                Integer.valueOf(ProjectStatus.WAIT_SURE.toString())//
                , Integer.valueOf(ProjectStatus.BUY_NOT_PASS.toString()),
                Integer.valueOf(ProjectStatus.OVER_TIME.toString())));
        return list.contains(status);
    }

    /**
     * @param session
     * @param project
     * @param page
     * @param sort
     * @param startTime
     * @param stopTime
     * @param bidTime
     * @param bidStopTime
     * @param roleId
     * @return
     * @description 项目投标列表
     * @author wwang
     * @date 2016-8-23
     */
    @RequestMapping("/bidder/bidList")
    @ResponseBody
    public JSONObject bidList(HttpSession session, ProjectInfo project, Page page, Sort sort, java.sql.Date startTime,
                              java.sql.Date stopTime, java.sql.Date bidTime, java.sql.Date bidStopTime, String roleId) {
        User user = (User) session.getAttribute("loginUser");
        RegisterUser registerUser = this.projectInfoService.get(RegisterUser.class, user.getRegisterId());
        // 结束时间处理，加一天
        stopTime = StringUtil.addOneDayDate(stopTime, 1);
        bidStopTime = StringUtil.addOneDayDate(bidStopTime, 1);

        projectInfoService.findBiddList(project, page, sort, startTime, stopTime, bidTime, bidStopTime);

        // 数据处理

        // 获取用户额所以角色ids
        String roleIds = "";
        List<Role> roleList = roleService.findRolesByUserId(user.getId());
        for (Role role : roleList) {
            roleIds += "'" + role.getId() + "',";
        }
        if (roleIds.length() > 0) {
            roleIds = roleIds.substring(0, roleIds.length() - 1);
        }

        List<ProjectInfo> pageList = page.getResult();
        for (ProjectInfo pro : pageList) {
            Dictionary dicProStatus = DictUtil.dict("proj_status", pro.getStatus() + "");
            if (dicProStatus != null) {
                pro.setStatusName(dicProStatus.getName());// 项目状态
            } else {
                pro.setStatusName("未知");// 项目状态
            }

            // 操作菜单
            String opera = "";
            List<ProjectOperation> list = roleService.findOperationByRoleIdAndStatus(roleIds, pro.getStatus() + "", PROCESS_DEFINATION_KEY);// 数据库中取
            // 缓存中取
            // List<ProjectOperation> list =
            // InitCacheData.getInstance().getCacheOperationData(CacheType.PROJ_OPERATION).get(ActivitiMap.getProperty(roleId)).get(pro.getStatus()+"");
            for (ProjectOperation op : list) {
                opera += op.getActionUrl().replace("row.id", pro.getId());
            }

            // 特殊的操作菜单
            // 投标信息
            if (registerUser != null) {
                ProjectBidInfo pb = projectInfoService.getProjectBidderByProjIdAndBidderId(pro.getId(),
                        registerUser.getId());
                // 投标按钮
                if (pro.getStatus() == Integer.valueOf(ProjectStatus.WAIT_SHOT.toString())) {// 项目状态为待开标
                    if (pb == null || pb.getFlag() != 1) {// 投标结果未提交
                        opera += Constant.PROJECTSHOT_OPERATION.replace("row.id", pro.getId());
                    } else {//提交了，显示撤销按钮
                        if (new Date().compareTo(pro.getBidStartTime()) <= 0) {//未到开标时间(当前时间小于且等于开标时间)
                            opera += Constant.PROJECTCANCELSHOT_OPERATION.replace("row.id", pro.getId());
                        }
                    }
                }

            }

            // 测试,投标操作
            if (Constant.IS_TEST_PROCESSINSTANCE) {
                opera += Constant.PROJECTSHOT_OPERATION.replace("row.id", pro.getId());
            }
            //设置操作菜单
            opera = setOperation(registerUser, pro, opera);

            // 添加项目详情操作
            opera += Constant.DETAILS_OPERATION.replace("row.id", pro.getId());
            pro.setOperation(opera);
        }
        return CommUtil.getPageJSONData(page, true);
    }

    /**
     * 设置投标人设置操作菜单
     *
     * @param registerUser
     * @param pro
     * @param opera
     * @return
     */
    private String setOperation(RegisterUser registerUser, ProjectInfo pro, String opera) {
        if (pro.getAuditable()) {//评标
            // 中标人,上传合同操作
            if (registerUser.getId().equals(pro.getWinningId())// 当中标人为当前登录人，项目状态为中标通知已发放
                    && (pro.getStatus().intValue() == Integer.valueOf(ProjectStatus.ALERT.toString()) || pro.getStatus()
                    .intValue() == Integer.valueOf(ProjectStatus.CONTACT_AUDIT_NOT_PASS.toString()))) {
                opera += Constant.UPLOADCONTRACT_OPERATION.replace("row.id", pro.getId());// 上传合同
                opera += Constant.WINBIDALERT_OPERATION.replace("row.id", pro.getId());// 打印中标通知书
                opera += Constant.PRINTCONTRACT_OPERATION.replace("row.id", pro.getId());// 打印合同
            }
            // 上传验收报告操作
            if (registerUser.getId().equals(pro.getWinningId())
                    && (pro.getStatus().intValue() == Integer.valueOf(ProjectStatus.SHOW_CONTACT_OVER.toString()) || pro
                    .getStatus().intValue() == Integer.valueOf(ProjectStatus.RECEIVING_UNAUTH.toString()))) {
                opera += Constant.PRINT_RECEIVINGREPORT_OPERATION.replace("row.id", pro.getId());// 验收报告打印
                opera += Constant.UPLOAD_RECEIVINGREPORT_OPERATION.replace("row.id", pro.getId());// 上传验收报告
            }
        } else {//不评标
            ProjectBidInfo bidInfo = this.projectInfoService.getProjectBidderByProjIdAndBidderId(pro.getId(), registerUser.getId());
            if (bidInfo != null//投标了
                    && bidInfo.getIsMultHit() != null && bidInfo.getIsMultHit() //中标人
                    && (pro.getStatus().intValue() == Integer.valueOf(ProjectStatus.ALERT.toString()) //
                    || pro.getStatus().intValue() == Integer.valueOf(ProjectStatus.CONTACT_AUDIT_NOT_PASS.toString()))) {
                opera += Constant.NB_WINBIDALERT_OPERATION.replace("row.id", pro.getId());// 打印中标通知书
                opera += Constant.PRINTCONTRACT_OPERATION.replace("row.id", pro.getId());// 打印合同
            }
            // 上传验收报告操作
            if (bidInfo != null//投标了
                    && bidInfo.getIsMultHit() != null && bidInfo.getIsMultHit() //中标人
                    && (pro.getStatus().intValue() == Integer.valueOf(ProjectStatus.SHOW_CONTACT_OVER.toString())//
                    || pro.getStatus().intValue() == Integer.valueOf(ProjectStatus.RECEIVING_UNAUTH.toString()))) {
                opera += Constant.NB_PRINT_RECEIVINGREPORT_OPERATION.replace("row.id", pro.getId());// 验收报告打印
            }
        }
        return opera;
    }

    // TODO wei Excel导出
    @RequestMapping(value = "/export", method = RequestMethod.POST)
    public ModelAndView export(HttpSession session, ProjectInfo project, Sort sort, java.sql.Date startTime,
                               java.sql.Date stopTime, Double startMoney, Double endMoney) {
        // String loginUserDeptUnit = null;
        //
        // User user = (User) session.getAttribute("loginUser");
        // int ifAdminType = 0;
        // if (user.getId().equals("1")) {
        // ifAdminType = 1;
        // } else {
        // Dept loginDept = (Dept)
        // InitCacheData.getInstance().getCacheData(CacheType.DEPT).get(user.getDeptId());
        // loginUserDeptUnit = loginDept.getpUnit();
        // }
        //
        // if (stopTime != null) {
        // Calendar c = Calendar.getInstance();
        // c.setTime(stopTime);
        // c.set(Calendar.DAY_OF_MONTH, c.get(Calendar.DAY_OF_MONTH) + 1);
        // stopTime = new java.sql.Date(c.getTime().getTime());
        // }
        // if (sort != null) {
        // String fields = sort.getFields();
        // if (!StringUtil.isEmpty(fields)) {
        // if (fields.indexOf("projectType") != -1) {
        // sort.setFields(sort.getFields().replace("projectType",
        // "goodsTypeId"));
        // }
        // if (fields.indexOf("moneyNatureName") != -1) {
        // sort.setFields(sort.getFields().replace("moneyNatureName",
        // "moneyNature"));
        // }
        // if (fields.indexOf("statusName") != -1) {
        // sort.setFields(sort.getFields().replace("statusName", "status"));
        // }
        // }
        // }
        //
        // List<PurchaseProject> list =
        // this.purchaseProjectServiceImpl.findAll(null, project, sort,
        // startTime, stopTime, startMoney, endMoney, user.getId(), ifAdminType,
        // loginUserDeptUnit, user);
        //
        // for (PurchaseProject pro : list) {
        // GoodsType goodsType = (GoodsType)
        // InitCacheData.getInstance().getCacheData(CacheType.GOODS_TYPE).get(pro.getGoodsTypeId());
        // if (goodsType == null) {
        // continue;
        // }
        // pro.setProjectType(goodsType.getName());
        // pro.setMoneyNatureName(DictUtil.dict("moneyNature",
        // pro.getMoneyNature()).getName());
        // pro.setStatusName(DictUtil.dict("is_approve",
        // pro.getStatus()).getName());
        // if (pro.getLimitTime() != null) {
        // if (pro.getLimitTime().getTime() <= new Date().getTime()) {
        // pro.setIfExpires(true);
        // } else {
        // pro.setIfExpires(false);
        // }
        // }
        // }
        //
        // // 组合excel信息
        // String excelName = "项目信息.xls";
        //
        // String titles[] = { "项目编码", "项目类型", "预算金额(元)", "资金性质", "创建时间",
        // "截止时间", "状态", "采购人" };
        // String dbColumnNames[] = { "projectNo", "projectType", "budgetMoney",
        // "moneyNatureName", "createTime", "limitTime", "statusName",
        // "userName" };
        // Integer colWidth[] = { 30, 30, 35, 30, 30, 40, 40, 40, 40 };
        //
        // // Excel操作
        // Map model = new HashMap();
        //
        // model.put("list", list);
        // model.put("titles", titles);
        // model.put("columns", dbColumnNames);
        // model.put(IExcel.COL_WIDTH, colWidth);
        // model.put("fileName", excelName);
        // model.put("sheetName", "统计");
        // ModelAndView mv = new ModelAndView(new JXLExcelView(), model);
        //
        // // 判断数据量(Excel只支持最大65536行)
        // if (list.size() >= 65530) {
        // mv.addObject("excel_error", "数据量过大!");
        // return null;
        // }

        return null;
    }

    /**
     * 获取项目类型
     *
     * @return
     */
    @RequestMapping("/getProjectTypes")
    @ResponseBody
    public JSONArray getProjectTypes(HttpSession session) {
        List<ProjectType> projectList = projectTypeService.findAll();
        return JSONArray.fromObject(projectList);
    }

    /**
     * 打开新增或修改页面
     *
     * @param projectId
     * @return
     */
    @RequestMapping("/input")
    public ModelAndView input(HttpSession session, String projectId, String show) {
        User user = (User) session.getAttribute("loginUser");
        ModelAndView mv = new ModelAndView("/auction/business/project-input");
        mv.addObject("user", user);
        ProjectInfo project = null;
        if (!StringUtil.isEmpty(projectId)) {
            project = this.projectInfoService.get(ProjectInfo.class, projectId);
            List<Resources> resList = FileResUtil.findResources(project.getId());
            mv.addObject("resList", resList);

            mv.addObject("project", project);
        }
        return mv;
    }

    @RequestMapping("/upload")
    public void upload(HttpServletRequest request, HttpServletResponse response, Integer functionFlog)
            throws IOException {
        PrintWriter out = response.getWriter();
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        // 取得request中的文件,获取一个list集合
        MultipartFile file = multipartRequest.getFile("Filedata");
        // 得到文件的相对路径
        String relativePath = File.separator + "project";
        String uploadPath = request.getSession().getServletContext().getRealPath("file_resource") + relativePath;
        File filePath = new File(uploadPath);
        // 判断文件夹是否存在，如果不存在给与创建出来
        if (!filePath.exists()) {
            filePath.mkdirs();
        }
        String fileName = file.getOriginalFilename();
        Resources res = new Resources();
        String exeName = fileName.substring(fileName.lastIndexOf("."), fileName.length());
        res.setExeName(exeName);
        res.setFilePath(relativePath);
        res.setFileSize(file.getSize());
        res.setOldName(fileName);
        res.setFunctionFlog(functionFlog);// 设置文件功能类型(交易申报表。。。。)
        FileResUtil.addFileRes(res); // 保存文件记录
        File newFile = new File(uploadPath, res.getId() + res.getExeName());
        file.transferTo(newFile);
        out.write(res.getId());
        out.flush();
        out.close();
    }

    /**
     * @param session
     * @param project
     * @param budgetMenuData
     * @return
     * @throws IOException
     * @description 项目保存
     * @author wei
     * @date 2016-8-15
     */
    @RequestMapping("/save")
    @ResponseBody
    public String save(HttpSession session, ProjectInfo project, String budgetMenuData) throws IOException {
        User user = (User) session.getAttribute("loginUser");
        // 项目保存
        projectInfoService.saveProject(user, budgetMenuData, project,
                Integer.valueOf(ProjectStatus.WAIT_SUBMIT.toString()));
        return Constant.SUCCESS;

    }

    /**
     * 项目提交
     *
     * @return
     */
    @RequestMapping("/doSubmit")
    @ResponseBody
    public String doSubmit(HttpSession session, ProjectInfo project, String budgetMenuData) {
        User user = (User) session.getAttribute("loginUser");
        projectInfoService.saveProject(user, budgetMenuData, project, Integer.valueOf(ProjectStatus.WAIT_AUDIT.toString()));
        LogUtil.addLog(new LogInfo("项目提交" + project.getName() + "项目状态,", user.getId(), user.getName(),
                String.valueOf(LogType.UPDATE.ordinal()), project.getClass().getSimpleName(), project.getId()));
        return Constant.SUCCESS;
    }

    /**
     * @param resId
     * @param response
     * @param request
     * @description 下载查看文件
     * @author wei
     * @date 2016-8-16
     */
    @RequestMapping("/fileView")
    public ModelAndView fileView(String resId, HttpServletResponse response, HttpServletRequest request) {
        @SuppressWarnings("unused")
        Resources resource = this.projectInfoService.get(Resources.class, resId);
        //
        // OutputStream os = null;
        // try {
        // if (resource == null) {
        // PrintWriter out = response.getWriter();
        // response.setHeader("Content-Disposition", "attachment;");
        // response.addHeader("Pargam", "no-cache");
        // response.addHeader("Cache-Control", "no-cache");
        // out.write("找不到对应的文件数据！");
        // out.flush();
        // } else {
        // String fileRealPath = resource.getFilePath() + File.separator +
        // resource.getId() + resource.getExeName();
        // String filePath =
        // request.getSession().getServletContext().getRealPath("/");
        // fileRealPath = filePath + "file_resource" + fileRealPath;
        // String fileName = resource.getOldName();
        // os = response.getOutputStream();
        //
        // //下载文件
        // FileDownload.processDownload(fileRealPath, fileName, request,
        // response);
        // }
        // } catch (Exception e) {
        // } finally {
        // if (os != null) {
        // try {
        // os.close();
        // } catch (IOException e) {
        // e.printStackTrace();
        // }
        // }
        // }
        ModelAndView model = new ModelAndView("word_plugin/fileShow");
        model.addObject("resId", resId);
        return model;
    }

    /**
     * @description 查看项目详情
     * @author xuyefei
     * @date 2016-4-13 下午07:50:45
     * @return ModelAndView
     */
    /**
     * @param session
     * @param projectId
     * @param type
     * @return
     */
    @RequestMapping("/getProjectDetail")
    public ModelAndView getProjectDetail(HttpSession session, String projectId, String type, String roleId) {
        User user = (User) session.getAttribute("loginUser");
        RegisterUser registerUser = this.projectInfoService.get(RegisterUser.class, user.getRegisterId());
        ProjectInfo project = projectInfoService.get(ProjectInfo.class, projectId);
        ModelAndView mv;
        mv = new ModelAndView("/proj/project-detail");
        if (!project.getAuditable()) {//不评标
            mv.setViewName("/projNB/public/project-detail");
        }
        mv.addObject("projectId", projectId);
        mv.addObject("roleId", roleId);

        // 1、=============数据信息查询========
        // 1.1基本信息
        ProjectBidInfo bidInfo = this.projectInfoService.getProjectBidderByProjIdAndBidderId(projectId,
                project.getWinningId());
        if (bidInfo != null) {
            RegisterUser bidder = this.userService.get(RegisterUser.class, project.getWinningId());
            if (bidder.getSocietyCode() != null) {
                bidInfo.setSocietyCode(bidder.getSocietyCode());
            }
        }


        // 数据处理
        project.setStatusName(DictUtil.dict("proj_status", project.getStatus() + "").getName());// 项目状态
        if (project.getFundFrom() != null && !StringUtil.isEmpty(project.getFundFrom())) {
            project.setFundFromName(DictUtil.dict("fundFroms", project.getFundFrom()).getName());// 资金来源
        }
        mv.addObject("project", project);
        mv.addObject("bidInfo", bidInfo);

        // 1.2、查询审核信息
        List<Comment> commentList = workflowProcessInstanceService.findCommentByTaskId(project.getWorkflowId());
        mv.addObject("commentList", commentList);

        // 1.3、查询采购人确认意见，项目负责人回复意见
        List<Comment> buyerManagerList = workflowProcessInstanceService.findCommentByTaskId(project.getWorkflowId(),
                "buyer_manager");
        mv.addObject("buyerManagerList", buyerManagerList);

        // 1.4、附件资源
        List<Resources> resList = FileResUtil.findResources(projectId);
        mv.addObject("resList", resList);

        // 1.5、查询专家、评标、质疑及公示信息
        // 专家信息
//		List<ProfessorInfo> professorList = professorService.getProfessorInfo(project.getId(), null);
        //专家
        ProfessorInfo pf = new ProfessorInfo();
        pf.setType("1");//专家
        pf.setProjId(projectId);
        List<ProfessorInfo> professorList = professorService.getProfessorInfoList(pf, null);
        mv.addObject("professorList", professorList);

        //监督员
        ProfessorInfo supervisor = new ProfessorInfo();
        supervisor.setType("2");//监督员
        supervisor.setProjId(projectId);
        List<ProfessorInfo> supervisorList = professorService.getProfessorInfoList(supervisor, null);
        mv.addObject("supervisorList", supervisorList);

        //业主
        ProfessorInfo owner = new ProfessorInfo();
        owner.setType("3");//业主
        owner.setProjId(projectId);
        List<ProfessorInfo> ownerList = professorService.getProfessorInfoList(owner, null);
        mv.addObject("ownerList", ownerList);

        // 1.6、合同审核
        List<Comment> contractAuditList = workflowProcessInstanceService.findCommentByTaskId(project.getWorkflowId(),
                "contract_audit");
        mv.addObject("contractAuditList", contractAuditList);

        // 1.6、验收报告审核
        List<Comment> receivingAuditList = workflowProcessInstanceService.findCommentByTaskId(project.getWorkflowId(),
                "receivingReson");
        mv.addObject("receivingAuditList", receivingAuditList);

        // 1.7、竞价公示暂停信息
        List<ProjectPause> shotPauseList = this.profectPauseService.getPrjectPause(project.getId(), "0");
        mv.addObject("shotPauseList", shotPauseList);

        // 1.8、中标公示暂停信息
        List<ProjectPause> bidPauseList = this.profectPauseService.getPrjectPause(project.getId(), "1");
        mv.addObject("bidPauseList", bidPauseList);

        // 1.9、质疑投诉答复处理结果
        List<WebContent> webContentList = this.webContentService.findListByProjectId(project.getId());
        mv.addObject("webContentList", webContentList);

        // 2、=============================数据信息权限控制=====================================
        // 2.1、是否显示审核信息
        String roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BUYER_ID + "," + ActivitiMap.ADMINISTRATOR_ID + ","
                + ActivitiMap.SUPERVISOR_ID + "," + ActivitiMap.SYSTEM_ID + "," + ActivitiMap.MANAGER_ID + "," + ActivitiMap.CENTERAUDITOR_ID;
        boolean isShowAudit = roleService.isPrivilege(user.getId(), roleIds);
        if (isShowAudit) {
            isShowAudit = project.getAuditId() == null ? false : true;// 无审核人id，不显示
        }
        mv.addObject("isShowAudit", isShowAudit);

        // 2.2、是否显示项目分配信息 (审核人、采购人、管理员、监督员、受理分配人、项目负责人)
        roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BUYER_ID + "," + ActivitiMap.ADMINISTRATOR_ID + ","
                + ActivitiMap.SUPERVISOR_ID + "," + ActivitiMap.SYSTEM_ID + "," + ActivitiMap.MANAGER_ID + "," + ActivitiMap.CENTERAUDITOR_ID;
        boolean isShowAssign = roleService.isPrivilege(user.getId(), roleIds);
        if (isShowAssign) {
            isShowAssign = project.getAssignId() == null ? false : true;// 无分配人id，不显示
        }
        mv.addObject("isShowAssign", isShowAssign);

        // 2.3、是否显示项目编制确认信息(审核人、采购人、管理员、监督员、受理分配人、项目负责人)
        roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BUYER_ID + "," + ActivitiMap.ADMINISTRATOR_ID + ","
                + ActivitiMap.SUPERVISOR_ID + "," + ActivitiMap.SYSTEM_ID + "," + ActivitiMap.MANAGER_ID + "," + ActivitiMap.CENTERAUDITOR_ID;
        boolean isShowCompileSure = roleService.isPrivilege(user.getId(), roleIds);
        if (isShowCompileSure) {
            isShowCompileSure = buyerManagerList == null || buyerManagerList.size() <= 0 ? false : true;// 无项目编制确认信息，不显示
        }
        mv.addObject("isShowCompileSure", isShowCompileSure);

        // 2.4、是否显示附件资源信息(审核人、采购人、管理员、监督员、受理分配人、项目负责人)
        roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BUYER_ID + "," + ActivitiMap.ADMINISTRATOR_ID + ","
                + ActivitiMap.SUPERVISOR_ID + "," + ActivitiMap.SYSTEM_ID + "," + ActivitiMap.MANAGER_ID + "," + ActivitiMap.CENTERAUDITOR_ID;
        boolean isShowAnnexes = roleService.isPrivilege(user.getId(), roleIds);
        // 无附件信息，不显示
        if (isShowAnnexes) {
            isShowAnnexes = isHasAnnexesInfo(resList);
        }
        mv.addObject("isShowAnnexes", isShowAnnexes);

        // 2.5、评标[专家信息](审核人、采购人、项目负责人、受理分配人、管理员、监督员)
        roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BUYER_ID + "," + ActivitiMap.ADMINISTRATOR_ID + ","
                + ActivitiMap.SUPERVISOR_ID + "," + ActivitiMap.SYSTEM_ID + "," + ActivitiMap.MANAGER_ID;
        boolean isShowQuestionAndBidInfo = roleService.isPrivilege(user.getId(), roleIds);
        if (registerUser != null) {// 投标人
            isShowQuestionAndBidInfo = isShowByProjectStatus(project.getStatus());
        }
        if (isShowQuestionAndBidInfo) {
            isShowQuestionAndBidInfo = professorList == null || professorList.size() <= 0 ? false : true;// 无专家信息，不显示
        }
        mv.addObject("isShowQuestionAndBidInfo", isShowQuestionAndBidInfo);

        // 2.12、公示信息(待开标后可见)
        boolean isShowPublicityInfo = true;
        if (isShowPublicityInfo && project.getAuditable()) {
            isShowPublicityInfo = project.getEvaluteEndTime() == null ? false : true;
        }
        mv.addObject("isShowPublicityInfo", isShowPublicityInfo);


        // 2.6、投标信息(项目负责人不可见非本人负责项目的投标信息，采购人在项目详情中仅可见中标人信息，非中标人投标信息不可见；投标人仅可见自己的投标信息，
        // 其他投标人信息不可见，项目分配人、系统管理员不可见投标信息，系统仅审核人和业务管理员可以看见所有项目的投标信息)
        boolean isShowBidList = true;//投标信息(投标信息列表+中标人信息)
        boolean isShowBidGrid = true;//投标信息列表
        boolean isShoter = false;//是否为投标人
        if (registerUser != null) {// 投标人
            isShowBidList = getBidderProjectStatusList(project.getStatus());
            isShoter = true;
        } else if ("buyer".equals(roleId)) {//采购人（在中标/流标确认之后看不见投标信息）
            isShowBidList = getBuyerProjectStatusList(project.getStatus());
        } else {
            isShowBidList = getOtherProjectStatusList(project.getStatus());
        }

//		if (isShowBidList) {//有数据时
//			roleIds = ActivitiMap.SYSTEM_ID + "," + ActivitiMap.ADMINISTRATOR_ID;
//			boolean isRole = roleService.isPrivilege(user.getId(), roleIds);
//			if (isRole) {// 项目分配人、系统管理员不可见投标信息列表
//				isShowBidList = false;
//			}
//
//			// 采购人只能查看中标人信息
//			roleIds = ActivitiMap.BUYER_ID;
//			boolean isBuyer = roleService.isPrivilege(user.getId(), roleIds);
//			if (isBuyer) {
//				isShowBidGrid=false;//投标信息列表不可看
//				isShowBidList = true;
//			}
//			
//			//项目负责人、业务管理员、审核人
//			roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BIZMANAGER_ID +"," + ActivitiMap.MANAGER_ID;
//			boolean isOtherRole = roleService.isPrivilege(user.getId(), roleIds);
//			if(isOtherRole){
//				isShowBidGrid=true;//投标信息可看
//				isShowBidList = true;
//			}
//		}

        mv.addObject("isShowBidList", isShowBidList);
        mv.addObject("isShowBidGrid", isShowBidGrid);
        mv.addObject("isShoter", isShoter);


        // 2.7 、项目编制信息(全员可见)
        boolean isShowCompile = project.getCompileTime() == null ? false : true;// 无项目编制日期且未提交，不显示
        if (project.getCompileTime() != null && user.getId().equals(project.getManageId())) {// 当前项目负责人已编制未提交，可显示
            isShowCompile = true;
        }
        mv.addObject("isShowCompile", isShowCompile);

        // 2.8、合同审核信息(审核人、采购人、管理员、监督员、受理分配人、项目负责人、中标人)
        roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BUYER_ID + "," + ActivitiMap.ADMINISTRATOR_ID + ","
                + ActivitiMap.SUPERVISOR_ID + "," + ActivitiMap.SYSTEM_ID + "," + ActivitiMap.MANAGER_ID + "," + ActivitiMap.CENTERAUDITOR_ID;
        boolean isShowContractAudit = roleService.isPrivilege(user.getId(), roleIds);
        if (registerUser != null) {
            if (project.getAuditable()) {//评标
                if (registerUser.getId().equals(project.getWinningId())) {// 为中标人
                    isShowContractAudit = true;
                }
            } else {//不评标
                ProjectBidInfo regBidInfo = this.projectInfoService.getProjectBidderByProjIdAndBidderId(projectId, registerUser.getId());
                if (regBidInfo != null && regBidInfo.getIsMultHit()) {// 为中标人
                    isShowContractAudit = true;
                }
            }

        }
        if (isShowContractAudit) {
            isShowContractAudit = isShowContractAudit(resList);// 判读是否有合同审核信息
        }
        mv.addObject("isShowContractAudit", isShowContractAudit);

        // 2.8、验收报告审核信息(审核人、采购人、管理员、监督员、受理分配人、项目负责人、中标人)
        roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BUYER_ID + "," + ActivitiMap.ADMINISTRATOR_ID + ","
                + ActivitiMap.SUPERVISOR_ID + "," + ActivitiMap.SYSTEM_ID + "," + ActivitiMap.MANAGER_ID;
        boolean isShowReceivingtAudit = roleService.isPrivilege(user.getId(), roleIds);
        if (registerUser != null) {
            if (project.getAuditable()) {//评标
                if (registerUser.getId().equals(project.getWinningId())) {// 为中标人
                    isShowReceivingtAudit = true;
                }
            } else {//不评标
                ProjectBidInfo regBidInfo = this.projectInfoService.getProjectBidderByProjIdAndBidderId(projectId, registerUser.getId());
                if (regBidInfo != null && regBidInfo.getIsMultHit()) {// 为中标人
                    isShowReceivingtAudit = true;
                }
            }

        }
        if (isShowReceivingtAudit) {
            isShowReceivingtAudit = isShowReceivingtAudit(resList);// 判读是否有验收报告审核信息
        }
        mv.addObject("isShowReceivingtAudit", isShowReceivingtAudit);

        // 2.9、竞价公示暂停
        roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BUYER_ID + "," + ActivitiMap.ADMINISTRATOR_ID + ","
                + ActivitiMap.SUPERVISOR_ID + "," + ActivitiMap.SYSTEM_ID + "," + ActivitiMap.MANAGER_ID + "," + ActivitiMap.BIZMANAGER_ID + "," + ActivitiMap.CENTERAUDITOR_ID;
        boolean isShowShotPause = roleService.isPrivilege(user.getId(), roleIds);
        if (registerUser != null) {// 投标人
            isShowShotPause = isShowByProjectStatus(project.getStatus());
        }
        if (shotPauseList == null || shotPauseList.size() <= 0) {
            isShowShotPause = false;
        }
        mv.addObject("isShowShotPause", isShowShotPause);

        // 2.10、中标公示暂停
        roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BUYER_ID + "," + ActivitiMap.ADMINISTRATOR_ID + ","
                + ActivitiMap.SUPERVISOR_ID + "," + ActivitiMap.SYSTEM_ID + "," + ActivitiMap.MANAGER_ID + "," + ActivitiMap.BIZMANAGER_ID + "," + ActivitiMap.CENTERAUDITOR_ID;
        boolean isShowBidPause = roleService.isPrivilege(user.getId(), roleIds);
        if (registerUser != null) {// 投标人
            isShowBidPause = isShowByProjectStatus(project.getStatus());
        }
        if (bidPauseList == null || bidPauseList.size() <= 0) {
            isShowBidPause = false;
        }
        mv.addObject("isShowBidPause", isShowBidPause);

        // 2.11、质疑投诉答复处理结果
        roleIds = ActivitiMap.AUDITOR_ID + "," + ActivitiMap.BUYER_ID + "," + ActivitiMap.ADMINISTRATOR_ID + ","
                + ActivitiMap.SUPERVISOR_ID + "," + ActivitiMap.SYSTEM_ID + "," + ActivitiMap.MANAGER_ID + "," + ActivitiMap.CENTERAUDITOR_ID;
        boolean isShowOppugn = roleService.isPrivilege(user.getId(), roleIds);
        if (registerUser != null) {// 投标人
            isShowOppugn = isShowByProjectStatus(project.getStatus());
        }
        if (isShowOppugn) {// 判断是否有信息
            isShowOppugn = webContentList == null || webContentList.size() <= 0 ? false : true;
        }
        mv.addObject("isShowOppugn", isShowOppugn);

        // 投标人中标确认后能看到
        boolean isBidder = true;
        if (registerUser != null) {// 投标人
            isBidder = isShowByProjectStatus(project.getStatus());
        }
        mv.addObject("isBidder", isBidder);

        // 是否有效标不足三家
        boolean isFlow = projectInfoService.getProjectBidderByProjId(projectId, false) < 3;// 是否流标
        mv.addObject("isFlow", isFlow);

        //是否为中标人
        boolean isHitBidder = false;
        if (registerUser != null) {
            if (project.getAuditable()) {
                if (registerUser != null) {// 投标人
                    if (project.getWinningId() != null// 中标人
                            && registerUser.getId().equals(project.getWinningId())) {
                        isHitBidder = true;
                    }
                }
            } else {
                ProjectBidInfo regBidInfo = this.projectInfoService.getProjectBidderByProjIdAndBidderId(projectId, registerUser.getId());
                if (regBidInfo != null && regBidInfo.getIsMultHit()) {// 为中标人
                    isHitBidder = true;
                }
            }
        }

        mv.addObject("isHitBidder", isHitBidder);

        //查询银行接口，履约保证金缴纳信息
        if (project.getExecuteBankAuthCode() != null) {
            List<Bank> bidBondInfoList = depositExecuteService.getDepositList(project.getId());
            mv.addObject("bidBondInfoList", bidBondInfoList);

            DepositReturn bidBondInfo = groupBidBondInfo(bidBondInfoList, bidInfo);//组装履约保证金信息对象
            mv.addObject("bidBondInfo", bidBondInfo);
        }

        //获取中标公示暂停 变更中标结果信息
        List<BidderChange> bidderChangeList = getEditHitResult(project.getId());
        mv.addObject("bidderChangeList", bidderChangeList);

        return mv;
    }

    /**
     * 获取中标公示暂停 变更中标结果信息
     *
     * @return
     */
    private List<BidderChange> getEditHitResult(String projectId) {
        List<BidderChange> bidderChangeList = professorService.findBidderChanageList(projectId);
        return bidderChangeList;
    }

    /**
     * 组装履约保证金信息对象
     *
     * @param bidInfo
     * @return
     */
    private DepositReturn groupBidBondInfo(List<Bank> list, ProjectBidInfo bidInfo) {
        if (list == null) {
            return null;
        }
        for (Bank bank : list) {
            if (bank.getInName() != null && bidInfo != null && bidInfo.getBidderName() != null
                    && bank.getInName().equals(bidInfo.getBidderName())) {
                DepositReturn dr = new DepositReturn();
                ComposeIdPK composeIdPK = new ComposeIdPK();
                composeIdPK.setCompanyName(bank.getInName());
                composeIdPK.setDepositType(Constant.DEPOSIT_TYPE_BIDDER);
                dr.setPk(composeIdPK);
                String date = bank.getInDate() + bank.getInTime(); // 拼接日期
                try {
                    dr.setTransTime(new SimpleDateFormat("yyyyMMddhhmmss").parse(date));// 时间
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                dr.setTnAmount(new BigDecimal(bank.getInAmount()));// 金额再次更新
                return dr;
            }
        }
        return null;
    }

    /**
     * @description 投标人是否能查看项目的信息
     * @author wwang
     * @date 2016年9月18日
     */
    private boolean isShowByProjectStatus(Integer status) {
        List<Integer> list = new ArrayList<Integer>();
        list.addAll(Arrays.asList(Integer.valueOf(ProjectStatus.SHOWING.toString()),
                Integer.valueOf(ProjectStatus.SHOWING_FLOW.toString()),
                Integer.valueOf(ProjectStatus.SHOW_OVER.toString()), Integer.valueOf(ProjectStatus.ALERT.toString()),
                Integer.valueOf(ProjectStatus.WAIT_CONTACT_AUDIT.toString()),
                Integer.valueOf(ProjectStatus.CONTACT_AUDIT_NOT_PASS.toString()),
                Integer.valueOf(ProjectStatus.SHOW_CONTACT.toString()),
                Integer.valueOf(ProjectStatus.SHOW_CONTACT_OVER.toString()),
                Integer.valueOf(ProjectStatus.WAIT_RECEIVING.toString()),
                Integer.valueOf(ProjectStatus.RECEIVING_UNAUTH.toString()),
                Integer.valueOf(ProjectStatus.RECEIVING_SHOWING.toString()),
                Integer.valueOf(ProjectStatus.WAIT_PROJ_OVER_SURE.toString()),
                Integer.valueOf(ProjectStatus.PROJ_OVER.toString()),
                Integer.valueOf(ProjectStatus.FLOW_DOWN.toString()), Integer.valueOf(ProjectStatus.CANCEL.toString()),
                Integer.valueOf(ProjectStatus.COMPAT_SHOW_PAUSE.toString()),
                Integer.valueOf(ProjectStatus.HIT_SHOW_PAUSE.toString()),
                Integer.valueOf(ProjectStatus.STATUS_LOCK.toString())));
        return list.contains(status);
    }

    /**
     * @param resList
     * @return
     * @description 判读是否有合同审核信息
     * @author wwang
     * @date 2016年9月19日
     */
    private boolean isShowContractAudit(List<Resources> resList) {
        // 判断是否有附件信息
        for (Resources res : resList) {
            if (UPLOADCONTRACT_RES == res.getFunctionFlog()) {
                return true;
            }
        }
        return false;
    }

    /**
     * @param resList
     * @return
     * @description 判读是否有验收报告审核信息
     * @author wwang
     * @date 2016年9月19日
     */
    private boolean isShowReceivingtAudit(List<Resources> resList) {
        // 判断是否有附件信息
        for (Resources res : resList) {
            if (AUDITREPORT_RES == res.getFunctionFlog()) {
                return true;
            }
        }
        return false;
    }

    /**
     * @param resList
     * @return
     * @description 判断是否有附件信息
     * @author wwang
     * @date 2016-9-2
     */
    private boolean isHasAnnexesInfo(List<Resources> resList) {
        // 判断是否有附件信息
        for (Resources res : resList) {
            if (EXPERTSERVICE_RES == res.getFunctionFlog()) {
                return true;
            }
            if (REVIEWSUMMARY_RES == res.getFunctionFlog()) {
                return true;
            }
            if (FIRSTTRIAL_RES == res.getFunctionFlog()) {
                return true;
            }
            if (SIGNIN_RES == res.getFunctionFlog()) {
                return true;
            }
            if (TENDER_RES == res.getFunctionFlog()) {
                return true;
            }
            if (bidSIGNIN_RES == res.getFunctionFlog()) {
                return true;
            }
        }
        return false;
    }

    /**
     * @description 获取投标人能查看项目投标信息项目状态集合
     * @author wwang
     * @date 2016年9月18日
     */
    private boolean getBidderProjectStatusList(Integer projectStatus) {
        List<Integer> list = new ArrayList<Integer>();
        list.addAll(Arrays.asList(Integer.valueOf(ProjectStatus.WAIT_SHOT.toString()),
                Integer.valueOf(ProjectStatus.SHOTING.toString()),
                Integer.valueOf(ProjectStatus.AUDITED_BEGIN.toString()),
                Integer.valueOf(ProjectStatus.AUDITED_END.toString()),
                Integer.valueOf(ProjectStatus.WAIT_WIN_SURE.toString()),
                Integer.valueOf(ProjectStatus.WAIT_FAIL_SURE.toString()),
                Integer.valueOf(ProjectStatus.SHOWING.toString()),
                Integer.valueOf(ProjectStatus.SHOWING_FLOW.toString()),
                Integer.valueOf(ProjectStatus.SHOW_OVER.toString()), Integer.valueOf(ProjectStatus.ALERT.toString()),
                Integer.valueOf(ProjectStatus.WAIT_CONTACT_AUDIT.toString()),
                Integer.valueOf(ProjectStatus.CONTACT_AUDIT_NOT_PASS.toString()),
                Integer.valueOf(ProjectStatus.SHOW_CONTACT.toString()),
                Integer.valueOf(ProjectStatus.SHOW_CONTACT_OVER.toString()),
                Integer.valueOf(ProjectStatus.WAIT_RECEIVING.toString()),
                Integer.valueOf(ProjectStatus.RECEIVING_UNAUTH.toString()),
                Integer.valueOf(ProjectStatus.RECEIVING_SHOWING.toString()),
                Integer.valueOf(ProjectStatus.WAIT_PROJ_OVER_SURE.toString()),
                Integer.valueOf(ProjectStatus.PROJ_OVER.toString()),
                Integer.valueOf(ProjectStatus.FLOW_DOWN.toString()), Integer.valueOf(ProjectStatus.CANCEL.toString()),
                Integer.valueOf(ProjectStatus.HIT_SHOW_PAUSE.toString()),
                Integer.valueOf(ProjectStatus.WAIT_WIN_CHOICE.toString()),
                Integer.valueOf(ProjectStatus.WAIT_ADDITION_FILE_FOR_FLOW.toString()),
                Integer.valueOf(ProjectStatus.STATUS_LOCK.toString())));// ?? 99
        return list.contains(projectStatus);
    }

    /**
     * @description 获取其他角色能查看项目投标信息项目状态集合
     * @author wwang
     * @date 2016年9月18日
     */
    private boolean getOtherProjectStatusList(Integer projectStatus) {
        List<Integer> list = new ArrayList<Integer>();
        list.addAll(Arrays.asList(Integer.valueOf(ProjectStatus.SHOTING.toString()),
                Integer.valueOf(ProjectStatus.AUDITED_BEGIN.toString()),
                Integer.valueOf(ProjectStatus.AUDITED_END.toString()),
                Integer.valueOf(ProjectStatus.WAIT_WIN_SURE.toString()),
                Integer.valueOf(ProjectStatus.WAIT_FAIL_SURE.toString()),
                Integer.valueOf(ProjectStatus.SHOWING.toString()),
                Integer.valueOf(ProjectStatus.SHOWING_FLOW.toString()),
                Integer.valueOf(ProjectStatus.SHOW_OVER.toString()),
                Integer.valueOf(ProjectStatus.ALERT.toString()),
                Integer.valueOf(ProjectStatus.WAIT_CONTACT_AUDIT.toString()),
                Integer.valueOf(ProjectStatus.CONTACT_AUDIT_NOT_PASS.toString()),
                Integer.valueOf(ProjectStatus.HIT_SHOW_PAUSE.toString()),
                Integer.valueOf(ProjectStatus.SHOW_CONTACT.toString()),
                Integer.valueOf(ProjectStatus.SHOW_CONTACT_OVER.toString()),
                Integer.valueOf(ProjectStatus.WAIT_RECEIVING.toString()),
                Integer.valueOf(ProjectStatus.RECEIVING_UNAUTH.toString()),
                Integer.valueOf(ProjectStatus.RECEIVING_SHOWING.toString()),
                Integer.valueOf(ProjectStatus.WAIT_PROJ_OVER_SURE.toString()),
                Integer.valueOf(ProjectStatus.PROJ_OVER.toString()),
                Integer.valueOf(ProjectStatus.FLOW_DOWN.toString()),
                Integer.valueOf(ProjectStatus.CANCEL.toString()),
                Integer.valueOf(ProjectStatus.WAIT_WIN_CHOICE.toString()),
                Integer.valueOf(ProjectStatus.WAIT_ADDITION_FILE_FOR_FLOW.toString()),
                Integer.valueOf(ProjectStatus.STATUS_LOCK.toString())));// ?? 99

        return list.contains(projectStatus);
    }


    /**
     * 采购人查看中标信息状态
     *
     * @param projectStatus
     * @return
     */
    private boolean getBuyerProjectStatusList(Integer projectStatus) {
        List<Integer> list = new ArrayList<Integer>();
        list.addAll(Arrays.asList(Integer.valueOf(ProjectStatus.SHOTING.toString()),
                Integer.valueOf(ProjectStatus.AUDITED_BEGIN.toString()),
                Integer.valueOf(ProjectStatus.AUDITED_END.toString()),
                Integer.valueOf(ProjectStatus.WAIT_WIN_SURE.toString()),
                Integer.valueOf(ProjectStatus.WAIT_WIN_CHOICE.toString()),
                Integer.valueOf(ProjectStatus.WAIT_ADDITION_FILE_FOR_FLOW.toString()),
                Integer.valueOf(ProjectStatus.WAIT_FAIL_SURE.toString())));
        return list.contains(projectStatus);
    }

    /**
     * 获取资金来源
     *
     * @return
     */
    @RequestMapping("/getFundFroms")
    @ResponseBody
    public JSONArray getFundFroms() {
        List<Dictionary> natures = DictUtil.dictChildren("fundFroms");
        return JSONArray.fromObject(natures);
    }

    /**
     * @param session
     * @param projectId
     * @return ModelAndView
     * @description 撤回、撤销项目页面
     * @author zhn
     * @date 2016-6-21 上午09:42:23
     */
    @RequestMapping("/getCancelReson")
    public ModelAndView getCancelReson(HttpSession session, String projectId, Integer type) {
        ModelAndView mv = new ModelAndView("/proj/cancel-reson-input");
        mv.addObject("projectId", projectId);
        mv.addObject("type", type);
        return mv;
    }

    /**
     * @description 采购人补充资料
     * @author shy
     */
    @RequestMapping("/complete")
    public ModelAndView getComplete(HttpSession session, String projectId) {
        ModelAndView mv = new ModelAndView("/proj/buyer/complete-file");
        mv.addObject("projectId", projectId);
        // 附件
        if (!StringUtil.isEmpty(projectId)) {
            List<Resources> resList = FileResUtil.findResources(projectId);
            mv.addObject("resList", resList);
        }
        return mv;
    }

    /**
     * 撤回操作，只有待审核状态才可以撤回
     *
     * @param projectId
     * @return
     */
    @RequestMapping("/callback")
    @ResponseBody
    public String callback(String projectId, ProjectInfo project, String budgetMenuData) {
        ProjectInfo pro = this.projectInfoService.get(ProjectInfo.class, projectId);
        // 并发处理
        if (Integer.valueOf(ProjectStatus.WAIT_AUDIT.toString()) == pro.getStatus()) {// 项目状态是待审核状态，允许撤回
            pro.setStatus(Integer.valueOf(ProjectStatus.WAIT_SUBMIT.toString()));// 设置待提交
            pro.setCancelReason(project.getCancelReason());// 撤回理由
            // 项目关联清单附件信息
            if (budgetMenuData != null) {
                String budgetMenuStr[] = budgetMenuData.split(",");
                Resources res = null;
                for (String budgetMenuId : budgetMenuStr) {
                    res = FileResUtil.getResources(budgetMenuId);
                    if (res != null) {
                        res.setBusinessId(pro.getId());
                        res.setFunctionFlog(1);
                        this.projectInfoService.saveOrUpdate(res);// 更新
                    }
                }
            }
            projectInfoService.saveOrUpdate(pro);
            return Constant.SUCCESS;
        }
        return Constant.UNSUCCESS;
    }

    /**
     * @param session
     * @param projectId
     * @param budgetMenuData
     * @return String
     * @description 撤销项目保存
     * @author zhn
     * @date 2016-6-21 上午09:45:57
     */
    @RequestMapping("/saveCancel")
    @ResponseBody
    public String saveCancel(HttpSession session, ProjectInfo project, String projectId, String budgetMenuData) {
        User user = (User) session.getAttribute("loginUser");
        ProjectInfo pro = this.projectInfoService.get(ProjectInfo.class, projectId);
        pro.setStatus(Integer.valueOf(ProjectStatus.CANCEL.toString()));// 状态显示为撤销
        pro.setCancelReason(project.getCancelReason());// 撤销理由

        // 项目关联清单附件信息(撤销理原因附件)
        if (budgetMenuData != null) {
            String budgetMenuStr[] = budgetMenuData.split(",");
            Resources res = null;
            for (String budgetMenuId : budgetMenuStr) {
                res = FileResUtil.getResources(budgetMenuId);
                if (res != null) {
                    res.setBusinessId(pro.getId());
                    res.setFunctionFlog(4);
                    this.projectInfoService.saveOrUpdate(res);// 更新
                }
            }
        }
        this.projectInfoService.saveOrUpdate(pro);
        return Constant.SUCCESS;
    }

    /**
     * @return String
     * @description 通过项目Id进行审核不通过操作
     */
    @RequestMapping("/audit/failApprove")
    @ResponseBody
    public String approve(HttpSession session, ProjectInfo projectInfo) {
        User suser = (User) session.getAttribute("loginUser");
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectInfo.getId());
        if (!StringUtil.isEmpty(projectInfo.getId()) && projectInfo.getStatus() != null) {
            pro.setStatus(Integer.valueOf(ProjectStatus.AUDIT_NOT_PASS.toString()));
            pro.setAuditId(suser.getId());
            pro.setAuditName(suser.getName());
            pro.setAuditTime(new Date());// 审核时间
            this.projectInfoService.saveOrUpdate(pro);

            // 流程 任务完成
            Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
            Map<String, Object> variables = new HashMap<String, Object>();
            variables.put("auditPass", false);
            variables.put("buyer", pro.getCreateId());
            // 添加批注
            workflowProcessInstanceService.addComment(suser.getLoginName(), task.getId(), pro.getWorkflowId(),
                    projectInfo.getCancelReason() + "</td><th>审核结果</th><td>审核不通过");
            workflowProcessInstanceService.complete(task.getId(), variables);
            return Constant.SAVE_SUCCESS;
        }
        return Constant.SAVE_UN_SUCCESS;
    }

    /**
     * @param session
     * @param projectId
     * @param status
     * @return ModelAndView
     * @description 项目审核不通过原因填写页面
     */
    @RequestMapping("/audit/failReson")
    @ResponseBody
    public ModelAndView failReason(HttpSession session, String projectId, String status) {
        if (!StringUtil.isEmpty(projectId) && !StringUtil.isEmpty(status)) {
            ModelAndView mv = new ModelAndView("/proj/audit/audit-fail-reson-input");
            mv.addObject("projectId", projectId);
            mv.addObject("status", status);
            return mv;
        }
        return null;
    }

    /**
     * 打开编制页面
     *
     * @param projectId
     * @return
     */
    @RequestMapping("/leader/establishInput")
    public ModelAndView establish(String projectId) {
        ModelAndView mv = new ModelAndView("/proj/leader/establish-input");

        ProjectInfo project = this.projectInfoService.get(ProjectInfo.class, projectId);
        DataSet dataset = dataSetService.get(DataSet.class, Constant.DATASET_ID);

        if (Constant.PROJECTCATAGORY_GOODSID.equals(project.getCatagoryId())) {// 货物类
            mv.setViewName("/proj/leader/establish-input/establish-goods-input");
        } else if (Constant.PROJECTCATAGORY_SERVICEID.equals(project.getCatagoryId())) {// 服务类
            mv.setViewName("/proj/leader/establish-input/establish-service-input");
        } else if (Constant.PROJECTCATAGORY_ENGINEERINGID.equals(project.getCatagoryId())) {// 工程类
            mv.setViewName("/proj/leader/establish-input/establish-engineering-input");
            if (project.getCompileTime() == null) {// 设置工程类的响应文件默认值
                project.setResponseFile(Constant.ENGINEERING_RESOINSEFILE);
            }
        } else if (Constant.PROJECTCATAGORY_PROPERTYID.equals(project.getCatagoryId())) {// 产权类
            // TODO 产权类的编制页面
            mv.setViewName("/proj/leader/establish-input");
        }

        // 默认采购确认时间当天的两个工作日
        Date buyerSureTime = this.holidaySetService.getWorkDayByDays(new Date(), 2);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<Resources> resList = FileResUtil.findResources(project.getId());
        mv.addObject("resList", resList);
        mv.addObject("project", project);
        mv.addObject("dataset", dataset);
        mv.addObject("buyerSureTime", sdf.format(buyerSureTime));
        return mv;
    }

    /**
     * @param session
     * @param project
     * @param budgetMenuData
     * @return
     * @throws Exception
     * @throws IOException
     * @description 项目编制保存
     * @author wei
     * @date 2016-8-15
     */
    @RequestMapping("/leader/establishSave")
    @ResponseBody
    public String saveEstablish(HttpSession session, HttpServletRequest request, ProjectInfo project,
                                String bidStartDateStr, String bidStartTimeStr, String qualifyFromDateStr, String qualifyEndDateStr,
                                String budgetMenuData) throws Exception {
        User user = (User) session.getAttribute("loginUser");
        // 开标时间处理
        Date bidStartTime = null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (bidStartDateStr != null && !bidStartDateStr.isEmpty()) {
            String bidStartStr = bidStartDateStr + " " + bidStartTimeStr + ":00:00";
            bidStartTime = StringUtil.StringToDate(bidStartStr);
        }

        // 保存项目信息
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, project.getId());
        pro.setDeliveryPoint(project.getDeliveryPoint());
        pro.setDeliveryLimit(project.getDeliveryLimit());
        pro.setPromissMoney(project.getPromissMoney());
        pro.setManageRoom(project.getManageRoom());
        pro.setQualifyFromDate(project.getQualifyFromDate());
        pro.setQualifyEndDate(project.getQualifyEndDate());
        pro.setValidTime(project.getValidTime());
        pro.setBidStartTime(bidStartTime);
        if (qualifyFromDateStr != null && !qualifyFromDateStr.isEmpty()) {
            pro.setQualifyFromDate(sdf.parse(qualifyFromDateStr + "-01 00:00:00"));// 合同开始时间
        }
        if (qualifyEndDateStr != null && !qualifyEndDateStr.isEmpty()) {
            pro.setQualifyEndDate(sdf.parse(qualifyEndDateStr + "-01 00:00:00"));// 合同结束时间
        }

        // 投标单位授权代表社保缴纳时间
        String socialSecurityBeginTimeStr = request.getParameter("socialSecurityBeginTimeStr");// 社保开始时间
        String socialSecurityEndTimeStr = request.getParameter("socialSecurityEndTimeStr");// 社保结束时间
        if (socialSecurityBeginTimeStr != null && !socialSecurityBeginTimeStr.isEmpty()) {
            pro.setSocialSecurityBeginTime(sdf.parse(socialSecurityBeginTimeStr + "-01 00:00:00"));// 社保开始时间
        }
        if (socialSecurityEndTimeStr != null && !socialSecurityEndTimeStr.isEmpty()) {
            pro.setSocialSecurityEndTime(sdf.parse(socialSecurityEndTimeStr + "-01 00:00:00"));// 社保结束时间
        }

        // 采购机构网站
        DataSet dataset = dataSetService.get(DataSet.class, Constant.DATASET_ID);
        pro.setProcurementAddr(dataset.getProcurementAddr());
        pro.setProcurementUrl(dataset.getProcurementUrl());
        pro.setOthereRequire(project.getOthereRequire());
        pro.setPerContent(project.getPerContent());
        pro.setContractAmount(project.getContractAmount());
        pro.setNoteText(project.getNoteText());// 前注文本
        pro.setBidType(project.getBidType());
        pro.setIsUnit(project.getIsUnit());
        pro.setCompileTime(new Date());// 编制时间
        pro.setResponseFile(project.getResponseFile());// 响应文件资料
        pro.setManagerTel(project.getManagerTel());// 项目负责人电话
        // 工程类属性
        pro.setTimeLimit(project.getTimeLimit());// 工程工期
        pro.setQualityYears(project.getQualityYears());// 质保期
        pro.setCaluType(project.getCaluType());// 计价方式
        pro.setBiderLevelRequire(project.getBiderLevelRequire());// 竞标人资质等级要求
        pro.setBiderManagerRequire(project.getBiderManagerRequire());// 竞标人项目经理资质等级要求
        pro.setRecommendBrand(project.getRecommendBrand());// 推荐品牌
        pro.setRemind(project.getRemind());// 注意事项
        pro.setParentProjCode(project.getParentProjCode());// 上次开标项目
        pro.setAchievement(project.getAchievement());//业绩
        // 项目关联清单附件信息
        if (budgetMenuData != null) {
            String budgetMenuStr[] = budgetMenuData.split(",");
            Resources res = null;
            for (String budgetMenuId : budgetMenuStr) {
                res = FileResUtil.getResources(budgetMenuId);
                if (res != null) {
                    res.setBusinessId(pro.getId());
                    this.projectInfoService.saveOrUpdate(res);// 更新
                }
            }
        }

        projectInfoService.saveOrUpdate(pro);
        return Constant.SUCCESS;

    }

    /**
     * @return String
     * @description 通过项目Id进行审核通过操作
     */
    @RequestMapping("/audit/approve")
    @ResponseBody
    public String flailApprove(HttpSession session, ProjectInfo projectInfo) {
        User suser = (User) session.getAttribute("loginUser");
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectInfo.getId());
        if (!StringUtil.isEmpty(projectInfo.getId()) && projectInfo.getStatus() != null) {


            // 流程 任务完成
            Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
            Map<String, Object> variables = new HashMap<String, Object>();
            variables.put("auditPass", true);
            // 添加批注
            workflowProcessInstanceService.addComment(suser.getLoginName(), task.getId(), pro.getWorkflowId(),
                    projectInfo.getCancelReason() + "</td><th>审核结果</th><td>审核通过");
            workflowProcessInstanceService.complete(task.getId(), variables);

            //确认下任务节点已经到了“分配受理人”节点才修改业务数据
            Task taskFind = workflowProcessInstanceService.findTask(pro.getWorkflowId());
            if (taskFind.getName().equals("分配受理人")) {
                pro.setStatus(Integer.valueOf(ProjectStatus.WAIT_APPLY.toString()));
                pro.setAuditId(suser.getId());
                pro.setAuditName(suser.getName());
                pro.setAuditTime(new Date());// 审核时间
                this.projectInfoService.saveOrUpdate(pro);
                return Constant.SAVE_SUCCESS;
            } else {
                return Constant.SAVE_UN_SUCCESS;
            }
        }
        return Constant.SAVE_UN_SUCCESS;
    }

    /**
     * @param session
     * @param projectId
     * @param status
     * @return ModelAndView
     * @description 项目审核通过原因填写
     */
    @RequestMapping("/audit/successReson")
    @ResponseBody
    public ModelAndView successReason(HttpSession session, String projectId, String status) {
        if (!StringUtil.isEmpty(projectId) && !StringUtil.isEmpty(status)) {
            ModelAndView mv = new ModelAndView("/proj/audit/audit-success-reson-input");
            mv.addObject("projectId", projectId);
            mv.addObject("status", status);
            return mv;
        }
        return null;
    }

    /**
     * @return ModelAndView
     * @description 分配项目
     * @author xuyefei
     * @date 2016-4-13 下午07:50:45
     */
    @RequestMapping("/assign/alertManagement")
    public ModelAndView alertManagement(String projectId) {
        ModelAndView mv = new ModelAndView("/proj/assign/alert-management-select");
        String roleId = ActivitiMap.MANAGER_ID;// 项目对应负责人的roleId
        List<User> userList = roleService.findUserByRoleId(roleId);

        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectId);
        if (!pro.getAuditable()) {//不评标
            roleId = ActivitiMap.CENTERAUDITOR_ID;//中心审核人
            userList = roleService.findUserByRoleId(roleId);
            mv.setViewName("/projNB/assign/assign-centerAuditor-list");
        }

        mv.addObject("userList", userList);
        mv.addObject("projectId", projectId);
        return mv;
    }

    /**
     * @return String
     * @description 通过项目Id进行分配操作
     */
    @RequestMapping("/assign/projectAssign")
    @ResponseBody
    public String projectAssign(HttpSession session, ProjectInfo projectInfo) {

        User suser = (User) session.getAttribute("loginUser");
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectInfo.getId());
        // 流程 任务完成
        Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
        if (!task.getName().equals(Constant.TASK_ASSIGN_NAME)) {
            return "noMatchTask";
        }

        pro.setStatus(Integer.valueOf(ProjectStatus.WAIT_COMPILE.toString()));
        pro.setAssignTime(new Date());
        pro.setAssignId(suser.getId());
        pro.setAssignName(suser.getName());
        pro.setManageId(projectInfo.getManageId());
        User manager = userService.get(User.class, projectInfo.getManageId());
        pro.setManageName(manager.getLoginName());
        pro.setManagerTel(manager.getTel());// 项目负责人联系电话

        // 设置项目编码
        pro.setCode(projectInfoService.generateProjectCode(pro));
        this.projectInfoService.saveOrUpdate(pro);

        // 任务完成（项目分配）
        Map<String, Object> variables = new HashMap<String, Object>();
        variables.put("manager", projectInfo.getManageId());
        workflowProcessInstanceService.complete(task.getId(), variables);

        return Constant.SAVE_SUCCESS;
    }

    /**
     * 投标项目页面
     *
     * @param session
     * @return
     */
    @RequestMapping("/bidder/shotInput")
    public ModelAndView shotInput(HttpSession session, String projectId) {
        User user = (User) session.getAttribute("loginUser");
        RegisterUser registerUser = this.projectInfoService.get(RegisterUser.class, user.getRegisterId());

        ModelAndView mv = new ModelAndView("/proj/bidder/shot-input");
        // 项目信息
        ProjectInfo project = projectInfoService.get(ProjectInfo.class, projectId);
        // 投标信息
        ProjectBidInfo pb = projectInfoService.getProjectBidderByProjIdAndBidderId(projectId, registerUser.getId());

        //判断是否评标
        if (!project.getAuditable()) {//不评标
            mv.setViewName("/projNB/bidder/shot-input");
        }

        mv.addObject("project", project);
        mv.addObject("pb", pb);

        // 附件
        if (!StringUtil.isEmpty(projectId)) {
            List<Resources> resList = FileResUtil.findResources(project.getId() + "," + registerUser.getId());
            mv.addObject("resList", resList);
        }
        return mv;
    }

    /**
     * 项目投标保存
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("/bidder/saveShot")
    @ResponseBody
    public String saveShot(HttpSession session, ProjectBidInfo projectBidInfo, String budgetMenuData) throws Exception {
        // 获取投标人信息
        User user = (User) session.getAttribute("loginUser");
        RegisterUser registerUser = this.projectInfoService.get(RegisterUser.class, user.getRegisterId());

        ProjectBidInfo projBid = this.projectInfoService.get(ProjectBidInfo.class, projectBidInfo.getId());
        ProjectInfo project = this.projectInfoService.get(ProjectInfo.class, projectBidInfo.getProjectId());
        // 判断是否已经投过标了
        ProjectBidInfo pb = projectInfoService.getProjectBidderByProjIdAndBidderId(projectBidInfo.getProjectId(),
                registerUser.getId());
        if (pb != null) {
            projBid = pb;
        }
        // 校验

        // 2、保证金缴纳校验
        // 2.1 判读是否为该项目类型的注册账号
        String registerCategory = this.registerUserService.getDepositCategoryName(registerUser.getId());
        if (!registerCategory.contains(project.getCatagoryName())) {
            return Constant.NO_REG_QUALIFICA_BID;
        }

        // 2.2 判断是否缴纳协议保证金
        String depositCategory = this.registerUserService.getDepositCategory(registerUser.getId());
        if (!depositCategory.contains(project.getCatagoryId()) && project.getPromissMoney() != 0) {// 保证金为0，不需要缴纳
            // 2.3 判断是否缴纳单项保证金
            int ifPaySingleDeposit = depositService.ifPaySingleDeposit(registerUser.getId(), project.getId(),
                    registerUser.getLoginName(), project.getName());
            if (ifPaySingleDeposit != 1 && project.getPromissMoney() != 0) {// 保证金为0，不需要缴纳//已交为1,未交为0,错误  为 -1
                if (ifPaySingleDeposit == 5) {//银行户名或开户行与系统帐户名或开户行不一致
                    return Constant.ATYPISM;
                }
                return Constant.NO_QUALIFICA_BID;
            }
        }

        // //2.3 判断是否缴纳单项保证金
        // int ifPaySingleDeposit =
        // depositService.ifPaySingleDeposit(registerUser.getId(),
        // project.getId(), registerUser.getLoginName(), project.getName());
        // if(ifPaySingleDeposit!=1&&project.getPromissMoney()!=0){//保证金为0，不需要缴纳
        // //已交为1,未交为0,错误 为 -1
        // return Constant.NO_QUALIFICA_BID;
        // }

        // 数据处理
        if (projBid == null) {
            projBid = new ProjectBidInfo();
        }
        projBid.setUserId(registerUser.getId());// 投标人id
        projBid.setBidderName(registerUser.getLoginName());// 单位名称
        projBid.setProjectId(projectBidInfo.getProjectId());// 项目id
        projBid.setProjectName(project.getName());// 项目名称
        projBid.setBidAmount(projectBidInfo.getBidAmount());// 报价总额
        Calendar cd = Calendar.getInstance();
        projBid.setBidTime(cd.getTime());// 投标时间
        projBid.setMillisecond(cd.get(Calendar.MILLISECOND));//投标时间毫米数
        projBid.setConsignor(projectBidInfo.getConsignor());// 委托人
        projBid.setConsignorIdCard(projectBidInfo.getConsignorIdCard());// 委托人身份证
        projBid.setConsignorPhone(projectBidInfo.getConsignorPhone());// 委托人联系方式
        this.projectInfoService.save(projBid);

        // 项目关联清单附件信息
        if (budgetMenuData != null) {
            String budgetMenuStr[] = budgetMenuData.split(",");
            Resources res = null;
            for (String budgetMenuId : budgetMenuStr) {
                res = FileResUtil.getResources(budgetMenuId);
                if (res != null) {
                    res.setBusinessId(projectBidInfo.getProjectId() + "," + registerUser.getId());// 项目id+用户Id
                    this.projectInfoService.saveOrUpdate(res);// 更新
                }
            }
        }

        // ?、禁投校验提醒
        if (registerUser.getForbidStartDate() != null) {
            Date forbidStartDate = registerUser.getForbidStartDate();// 禁投开始日期
            Date forbidEndDate = registerUser.getForbidEndDate();// 禁投结束日期
            if (forbidStartDate != null && forbidEndDate != null && forbidEndDate.compareTo(new Date()) >= 0) {// 禁投结束日期大于当前日期
                return Constant.PROJECT_NO_BID_SAVE_UNSUCCESS;
            }
        }

        return Constant.SUCCESS;
    }

    /**
     * 项目投标提交
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("/bidder/doSubmitShot")
    @ResponseBody
    public String doSubmitShot(HttpSession session, ProjectBidInfo projectBidInfo, String budgetMenuData)
            throws Exception {
        User user = (User) session.getAttribute("loginUser");
        RegisterUser registerUser = this.projectInfoService.get(RegisterUser.class, user.getRegisterId());

        ProjectBidInfo projBid = null;
        if (!"".equals(projectBidInfo.getId())) {
            projBid = this.projectInfoService.get(ProjectBidInfo.class, projectBidInfo.getId());
        }
        ProjectInfo project = this.projectInfoService.get(ProjectInfo.class, projectBidInfo.getProjectId());
        // 判断是否已经投过标了
        boolean isBid = projectInfoService.isBidByProjIdAndBidderId(project.getId(), registerUser.getId());
        if (isBid) {
            return Constant.EXIT_BID;
        }

        // 是否能提交投标结果判断
        // 开标前30分钟，才能提交
        Date openBIdBeforeTime = StringUtil.computeDate(project.getBidStartTime(), 0, 0, 0, 0, -30, 0);
        if (new Date().compareTo(project.getBidStartTime()) <= 0// 当前时间小于且等于开标时间
                && new Date().compareTo(openBIdBeforeTime) >= 0// 当前时间大于等于开标前的30分钟
                && project.getStatus() == Integer.valueOf(ProjectStatus.WAIT_SHOT.toString())) {// 项目状态为待开标
            if (projBid == null || projBid.getFlag() != 1) {// 投标结果未提交
                // 校验
                // 1、禁投校验
                // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                // if (registerUser.getForbidStartDate() != null) {
                // Date forbidStartDate = registerUser.getForbidStartDate();//
                // 禁投开始日期
                // Date forbidEndDate = registerUser.getForbidEndDate();//
                // 禁投结束日期
                // if (forbidStartDate != null && forbidEndDate != null
                // && forbidEndDate.compareTo(new Date()) >= 0) {// 禁投结束日期大于当前日期
                // return Constant.PROJECT_NO_BID_SAVE_UNSUCCESS;
                // }
                // }

                // 2、保证金缴纳校验
                // 2.1 判读是否为该项目类型的注册账号
                String registerCategory = this.registerUserService.getDepositCategoryName(registerUser.getId());
                if (!registerCategory.contains(project.getCatagoryName())) {
                    return Constant.NO_REG_QUALIFICA_BID;
                }

                // 2.2 判断是否缴纳协议保证金
                String depositCategory = this.registerUserService.getDepositCategory(registerUser.getId());
                if (!depositCategory.contains(project.getCatagoryId()) && project.getPromissMoney() != 0) {// 保证金为0，不需要缴纳
                    // 2.3 判断是否缴纳单项保证金
                    int ifPaySingleDeposit = depositService.ifPaySingleDeposit(registerUser.getId(), project.getId(),
                            registerUser.getLoginName(), project.getName());
                    if (ifPaySingleDeposit != 1 && project.getPromissMoney() != 0) {// 保证金为0，不需要缴纳//已交为1,未交为0,错误 为 -1
                        if (ifPaySingleDeposit == 5) {//银行户名或开户行与系统帐户名或开户行不一致
                            return Constant.ATYPISM;
                        }
                        return Constant.NO_QUALIFICA_BID;
                    }
                }

                // 数据处理
                if (projBid == null) {
                    projBid = new ProjectBidInfo();
                }

                projBid.setUserId(registerUser.getId());// 投标人id
                projBid.setBidderName(registerUser.getLoginName());// 单位名称
                projBid.setProjectId(projectBidInfo.getProjectId());// 项目id
                projBid.setProjectName(project.getName());// 项目名称
                projBid.setBidAmount(projectBidInfo.getBidAmount());// 报价总额
                Calendar cd = Calendar.getInstance();
                projBid.setBidTime(cd.getTime());// 投标时间
                projBid.setMillisecond(cd.get(Calendar.MILLISECOND));//投标时间毫米数
                projBid.setFlag(1);// 标识为 已提交
                projBid.setConsignor(projectBidInfo.getConsignor());// 委托人
                projBid.setConsignorIdCard(projectBidInfo.getConsignorIdCard());// 委托人身份证
                projBid.setConsignorPhone(projectBidInfo.getConsignorPhone());// 委托人联系方式
                // 报价大于项目预算时自动无效标处理
                if (projBid.getBidAmount() > project.getBudgetAmount()) {
                    projBid.setEvalutionResult(2);// 无效标
                    return "outBudgetAmount";
                }

                // 项目关联清单附件信息(撤销理原因附件)
                if (budgetMenuData != null) {
                    String budgetMenuStr[] = budgetMenuData.split(",");
                    Resources res = null;
                    for (String budgetMenuId : budgetMenuStr) {
                        res = FileResUtil.getResources(budgetMenuId);
                        if (res != null) {
                            res.setBusinessId(projectBidInfo.getProjectId() + "," + registerUser.getId());// 项目id+用户Id
                            this.projectInfoService.saveOrUpdate(res);// 更新
                        }
                    }
                }

                // ?、禁投校验提醒
                if (registerUser.getForbidStartDate() != null) {
                    Date forbidStartDate = registerUser.getForbidStartDate();// 禁投开始日期
                    Date forbidEndDate = registerUser.getForbidEndDate();// 禁投结束日期
                    if (forbidStartDate != null && forbidEndDate != null && forbidEndDate.compareTo(new Date()) >= 0) {// 禁投结束日期大于当前日期
                        return Constant.PROJECT_NO_BID_SAVE_UNSUCCESS;
                    }
                }

                this.projectInfoService.saveOrUpdate(projBid);
                System.err.println("当前时间在开标前30分钟之内,可进行投标提交操作!");
                return Constant.SUCCESS;
            }
        }

        return Constant.NO_BID_SUBMIT_UNSUCCESS;
    }

    /**
     * 项目编制提交
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("/leader/doSubmitCompile")
    @ResponseBody
    public String doSubmitCompile(HttpSession session, HttpServletRequest request, ProjectInfo project,
                                  String bidStartDateStr, String bidStartTimeStr, String qualifyFromDateStr, String qualifyEndDateStr,
                                  String budgetMenuData, String replyContent) throws Exception {
        User user = (User) session.getAttribute("loginUser");

        // 开标时间处理
        String bidStartStr = bidStartDateStr + " " + bidStartTimeStr + ":00:00";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date bidStartTime = StringUtil.StringToDate(bidStartStr);

        //TODO 开标时间校验(9点和15点只能设置两个项目)
        boolean isOkBidDate = bidDateVerify(bidStartTime);
        if (!isOkBidDate) {//当前时间已有两个项目了
            return "existtwoproject";
        }

        // ==================
        // 保存项目信息
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, project.getId());
        pro.setDeliveryPoint(project.getDeliveryPoint());
        pro.setDeliveryLimit(project.getDeliveryLimit());
        pro.setPromissMoney(project.getPromissMoney());
        pro.setManageRoom(project.getManageRoom());
        pro.setQualifyFromDate(project.getQualifyFromDate());
        pro.setQualifyEndDate(project.getQualifyEndDate());
        pro.setValidTime(project.getValidTime());
        pro.setBidStartTime(bidStartTime);
        if (qualifyFromDateStr != null && !qualifyFromDateStr.isEmpty()) {
            pro.setQualifyFromDate(sdf.parse(qualifyFromDateStr + "-01 00:00:00"));// 合同开始时间
        }
        if (qualifyEndDateStr != null && !qualifyEndDateStr.isEmpty()) {
            pro.setQualifyEndDate(sdf.parse(qualifyEndDateStr + "-01 00:00:00"));// 合同结束时间
        }
        // 投标单位授权代表社保缴纳时间
        String socialSecurityBeginTimeStr = request.getParameter("socialSecurityBeginTimeStr");// 社保开始时间
        String socialSecurityEndTimeStr = request.getParameter("socialSecurityEndTimeStr");// 社保结束时间
        if (socialSecurityBeginTimeStr != null && !socialSecurityBeginTimeStr.isEmpty()) {
            pro.setSocialSecurityBeginTime(sdf.parse(socialSecurityBeginTimeStr + "-01 00:00:00"));// 社保开始时间
        }
        if (socialSecurityEndTimeStr != null && !socialSecurityEndTimeStr.isEmpty()) {
            pro.setSocialSecurityEndTime(sdf.parse(socialSecurityEndTimeStr + "-01 00:00:00"));// 社保结束时间
        }
        // 采购机构网站
        DataSet dataset = dataSetService.get(DataSet.class, Constant.DATASET_ID);
        pro.setProcurementAddr(dataset.getProcurementAddr());
        pro.setProcurementUrl(dataset.getProcurementUrl());
        pro.setOthereRequire(project.getOthereRequire());
        pro.setPerContent(project.getPerContent());
        pro.setContractAmount(project.getContractAmount());
        pro.setNoteText(project.getNoteText());// 前注文本
        pro.setBidType(project.getBidType());
        pro.setIsUnit(project.getIsUnit());
        pro.setCompileTime(new Date());// 编制时间
        pro.setResponseFile(project.getResponseFile());// 响应文件资料
        pro.setManagerTel(project.getManagerTel());// 项目负责人电话
        // 设置项目状态
        pro.setStatus(Integer.valueOf(ProjectStatus.WAIT_SURE.toString()));
        // 工程类属性
        pro.setTimeLimit(project.getTimeLimit());// 工程工期
        pro.setQualityYears(project.getQualityYears());// 质保期
        pro.setCaluType(project.getCaluType());// 计价方式
        pro.setBiderLevelRequire(project.getBiderLevelRequire());// 竞标人资质等级要求
        pro.setBiderManagerRequire(project.getBiderManagerRequire());// 竞标人项目经理资质等级要求
        pro.setRecommendBrand(project.getRecommendBrand());// 推荐品牌
        pro.setRemind(project.getRemind());// 注意事项
        pro.setParentProjCode(project.getParentProjCode());// 上次开标项目
        pro.setAchievement(project.getAchievement());//业绩
        // 项目关联清单附件信息
        if (budgetMenuData != null) {
            String budgetMenuStr[] = budgetMenuData.split(",");
            Resources res = null;
            for (String budgetMenuId : budgetMenuStr) {
                res = FileResUtil.getResources(budgetMenuId);
                if (res != null) {
                    res.setBusinessId(pro.getId());
                    this.projectInfoService.saveOrUpdate(res);// 更新
                }
            }
        }

        this.projectInfoService.saveOrUpdate(pro);
        // 生成world编制文档
        generateWord(request, pro);

        // 流程 完成任务
        Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
        if (replyContent != null && !replyContent.equals("")) {
            // 添加确认意见评论
            workflowProcessInstanceService.addComment(pro.getCreateId(), task.getId(), pro.getWorkflowId(),
                    "buyer_manager", replyContent);
        }

        // 设置超时确认时间
        Map<String, Object> variables = new HashMap<String, Object>();
        variables.put("buyTime", StringUtil.getISODate(project.getValidTime()));
        workflowProcessInstanceService.complete(task.getId(), variables);

        return Constant.SUCCESS;
    }


    /**
     * @description 同一天，同一时间仅允许2个项目开标
     * @author shy
     */
    public boolean bidDateVerify(Date date) {
        boolean flag = true;
        DataSet dataset = this.projectInfoService.get(DataSet.class, Constant.DATASET_ID);
        int evaluateRooms = dataset.getEvaluateRooms();
        int projectCount = this.projectBidService.getProjectCount(date);
        if (projectCount >= evaluateRooms) {
            flag = false;
        }
        return flag;
    }


    /**
     * 采购确认提交
     *
     * @param projectId
     * @return
     */
    @RequestMapping("/buyer/buyerSure")
    @ResponseBody
    public String buyerSure(String projectId, String cancelReason, Integer type, String budgetMenuData) {
        //当前时间已超过16:30,无法进行确认
        String nowStr = DateUtils.simpleDateFormat(new Date(), "yyyy-MM-dd");
        Date validateTime = DateUtils.simpleDateFormat(nowStr + " 16:30:00", "yyyy-MM-dd HH:mm:ss");
        if (new Date().getTime() >= validateTime.getTime()) {
            return "false";
        }

        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectId);

        // 流程 完成任务
        Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());

        Map<String, Object> variables = new HashMap<String, Object>();
        if (type == 0) {// 不通过
            variables.put("competPass", false);
            // 设置项目状态
            pro.setStatus(Integer.valueOf(ProjectStatus.BUY_NOT_PASS.toString()));

            // 添加确认意见评论
            workflowProcessInstanceService.addComment(pro.getCreateId(), task.getId(), pro.getWorkflowId(), "buyer_manager",
                    cancelReason + "</td><th>结果</th><td>不通过");
        } else {// 通过

            // 推送信息至银行（投标保证金）
            boolean result = postBank(pro);
            if (!result) {//投标保证金推送失败
                return "postbankfaill";
            }

//			// 推送信息至银行（履约保证金）
//			boolean executeResult = postBankFromExecute(pro);
//			if (!executeResult) {//履约保证金推送失败
//				return "postbanexecutekfaill";
//			}

            variables.put("competPass", true);
            // 设置项目状态
            pro.setStatus(Integer.valueOf(ProjectStatus.WAIT_SHOT.toString()));
            // 设置开标时间
            variables.put("timeCompet", StringUtil.getISODate(pro.getBidStartTime()));

            // 添加确认意见评论
            workflowProcessInstanceService.addComment(pro.getCreateId(), task.getId(), pro.getWorkflowId(), "buyer_manager",
                    cancelReason + "</td><th>结果</th><td>通过");
        }
        workflowProcessInstanceService.complete(task.getId(), variables);

        projectInfoService.saveOrUpdate(pro);

        return Constant.SUCCESS;
    }

    /**
     * 推送信息至银行操作（投标保证金）
     *
     * @return
     */
    public boolean postBank(ProjectInfo pi) {

        // 第一次
        int n = 1;

        try {
            int _ret = depositService.regToBank(pi.getId());
            if (_ret == 1) {
                System.out.print("注册成功!");
                return true;
            } else {
                System.out.print("注册 不成功");
                n++;
            }
        } catch (IOException e) {
            System.out.print("注册 不成功，出现异常");
            e.printStackTrace();
            n++;
        }

        // 第二次
        try {
            int _ret = depositService.regToBank(pi.getId());
            if (_ret == 1) {
                System.out.print("第二次注册成功!");
                return true;
            } else {
                System.out.print("第二次注册 不成功");
                n++;
            }
        } catch (IOException e) {
            System.out.print("第二次注册 不成功，出现异常");
            e.printStackTrace();
            n++;
        }

        // 第三次
        try {
            int _ret = depositService.regToBank(pi.getId());
            if (_ret == 1) {
                System.out.print("第三次注册成功!");
                return true;
            } else {
                System.out.print("第三次注册 不成功");
                n++;
            }
        } catch (IOException e) {
            System.out.print("第三次注册 不成功，出现异常");
            e.printStackTrace();
            n++;
        }

        if (n >= 3) {
            // 发布三次未注册上的消息给系统管理 员
           // this.notifyService.savePostBankFallNotify(pi);
            return false;
        }
        return false;
    }


    /**
     * 采购补充资料
     *
     * @param projectId
     * @return
     * @author shy
     */
    @RequestMapping("/buyer/completeSave")
    @ResponseBody
    public String completeSave(String projectId, String budgetMenuData) {
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectId);
        // 项目关联清单附件信息
        if (budgetMenuData != null) {
            String budgetMenuStr[] = budgetMenuData.split(",");
            Resources res = null;
            for (String budgetMenuId : budgetMenuStr) {
                res = FileResUtil.getResources(budgetMenuId);
                if (res != null) {
                    res.setBusinessId(pro.getId());
                    this.projectInfoService.saveOrUpdate(res);// 更新
                }
            }
        }
        return Constant.SUCCESS;
    }

    /**
     * @param id
     * @return
     * @description 发放中标通知书
     * @author wwang
     * @date 2016-8-24
     */
    @RequestMapping("/leader/noticBidInfo")
    @ResponseBody
    public String noticBidInfo(String id) {
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, id);
        pro.setStatus(Integer.valueOf(ProjectStatus.ALERT.toString()));// 中标通知书已发放
        pro.setReleaseAlertDoc(new Date());
        this.projectInfoService.saveOrUpdate(pro);

        // 流程 完成任务
        Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
        Map<String, Object> variables = new HashMap<String, Object>();
        List<String> rec = new ArrayList<String>();
        rec.add(pro.getWinningId());// 中标人
        rec.add(pro.getCreateId());// 采购方
        variables.put("receivers", rec);
        workflowProcessInstanceService.complete(task.getId(), variables);

        return Constant.SUCCESS;
    }

    /**
     * @param session
     * @param projectId
     * @return ModelAndView
     * @description 上传合同页面
     * @author zhn
     * @date 2016-6-21 上午09:42:23
     */
    @RequestMapping("/uploadContract")
    public ModelAndView uploadContract(HttpSession session, String projectId, Integer type) {
        ModelAndView mv = new ModelAndView("/proj/buyer/contract-input");
        mv.addObject("projectId", projectId);
        mv.addObject("type", type);
        return mv;
    }

    /**
     * 上传合同
     *
     * @param projectId
     * @return
     */
    @RequestMapping("/doSubmitContract")
    @ResponseBody
    public String doSubmitContract(HttpSession session, HttpServletRequest request, String projectId,
                                   String budgetMenuData) {
        User user = (User) session.getAttribute("loginUser");

        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectId);
        // 上传人信息
        pro.setContactUpTime(new Date());
        pro.setContactUpUserId(user.getId());
        pro.setContactUpUserName(user.getLoginName());
        // 保存文档到res数据
        List<Resources> resList = FileResUtil.findResources(pro.getId());
        // 删除之前的生成的竞价文件
        for (Resources resources : resList) {
            if (resources.getFunctionFlog() == 7) {// 合同
                FileResUtil.deleteFile(resources.getId(), request);
            }
        }

        //未上传合同
        if (budgetMenuData == null && "".equals(budgetMenuData)) {
            return "nocontract";
        }

        // 项目关联清单附件信息
        if (budgetMenuData != null) {
            String budgetMenuStr[] = budgetMenuData.split(",");
            Resources res = null;
            for (String budgetMenuId : budgetMenuStr) {
                res = FileResUtil.getResources(budgetMenuId);
                if (res != null) {
                    res.setBusinessId(pro.getId());
                    this.projectInfoService.saveOrUpdate(res);// 更新
                }
            }
        }
        pro.setStatus(Integer.valueOf(ProjectStatus.WAIT_CONTACT_AUDIT.toString()));// 合同待审核
        projectInfoService.saveOrUpdate(pro);

        // 流程 完成任务
        Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
        workflowProcessInstanceService.complete(task.getId(), null);

        LogUtil.addLog(new LogInfo("上传合同" + pro.getName() + "项目状态,", user.getId(), user.getName(),
                String.valueOf(LogType.UPDATE.ordinal()), pro.getClass().getSimpleName(), pro.getId()));
        return Constant.SUCCESS;
    }

    /**
     * 项目合同审核操作
     *
     * @param projectId
     * @return
     */
    @RequestMapping("/leader/contractAudit")
    @ResponseBody
    public String contractAudit(HttpSession session, String projectId, String reason, Integer type,
                                String budgetMenuData) throws Exception {
        User user = (User) session.getAttribute("loginUser");
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectId);

        // 流程 完成任务
        Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
        Map<String, Object> variables = new HashMap<String, Object>();
        if (type == 0) {// 不通过
            variables.put("contactPass", false);
            // 设置项目状态
            pro.setStatus(Integer.valueOf(ProjectStatus.CONTACT_AUDIT_NOT_PASS.toString()));
            // 保存审核意见
            workflowProcessInstanceService.addComment(user.getId(), task.getId(), pro.getWorkflowId(), "contract_audit",
                    reason + "</td><th>审核结果</th><td>审核不通过");
        } else {// 通过
            variables.put("contactPass", true);
            // 设置项目状态
            pro.setStatus(Integer.valueOf(ProjectStatus.SHOW_CONTACT.toString()));
            // 保存审核意见
            workflowProcessInstanceService.addComment(user.getId(), task.getId(), pro.getWorkflowId(), "contract_audit",
                    reason + "</td><th>审核结果</th><td>审核通过");
        }


        // 设置合同公示时间
        // 获取时间
        DataSet dataset = dataSetService.get(DataSet.class, Constant.DATASET_ID);
        int publicity = dataset.getPublicity();// 公示天数
        // String publicityDate = StringUtil.computeDate(new Date(), "00:00:00",
        // publicity+1);//公示时间
        String publicityDate = DateUtils.computeWorkDayDateStr(holidaySetService, new Date(), publicity);// (工作日)公示时间
        variables.put("timeContact", StringUtil.getISODate(publicityDate));

        // 保存合同开始时间，结束时间
        pro.setContactBeginTime(new Date());
        pro.setContactEndTime(StringUtil.StringToDate(publicityDate));
        this.projectInfoService.saveOrUpdate(pro);

        workflowProcessInstanceService.complete(task.getId(), variables);

        return Constant.SUCCESS;
    }

    /**
     * @param projectId
     * @return
     * @description 结项操作
     * @author wwang
     * @date 2016-8-24
     */
    @RequestMapping("/leader/endProject")
    @ResponseBody
    public String endProject(String projectId) {
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectId);
        pro.setStatus(Integer.valueOf(ProjectStatus.PROJ_OVER.toString()));
        pro.setEndTime(new Date());
        // 项目跨度
        int allDays = DateUtils.daysBetween(pro.getCreateTime(), pro.getEndTime());
        pro.setAllDays(allDays);
        this.projectInfoService.saveOrUpdate(pro);

        // 流程 完成任务
        Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
        workflowProcessInstanceService.complete(task.getId(), null);

        return Constant.SUCCESS;
    }

    /**
     * @param request
     * @param project
     * @param bidStartDateStr
     * @param bidStartTimeStr
     * @param qualifyFromDateStr
     * @param qualifyEndDateStr
     * @param budgetMenuData
     * @return
     * @throws Exception
     * @description 生成world文档预览
     * @author wwang
     * @date 2016年9月21日
     */
    @RequestMapping("/generateWord")
    @ResponseBody
    public String generateWord(HttpServletRequest request, ProjectInfo project, String bidStartDateStr,
                               String bidStartTimeStr, String qualifyFromDateStr, String qualifyEndDateStr, String budgetMenuData)
            throws Exception {
        // 开标时间处理
        Date bidStartTime = null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (bidStartDateStr != null && !bidStartDateStr.isEmpty()) {
            String bidStartStr = bidStartDateStr + " " + bidStartTimeStr + ":00:00";
            bidStartTime = StringUtil.StringToDate(bidStartStr);
        }

        // 保存项目信息
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, project.getId());
        pro.setDeliveryPoint(project.getDeliveryPoint());
        pro.setDeliveryLimit(project.getDeliveryLimit());
        pro.setPromissMoney(project.getPromissMoney());
        pro.setManageRoom(project.getManageRoom());
        pro.setQualifyFromDate(project.getQualifyFromDate());
        pro.setQualifyEndDate(project.getQualifyEndDate());
        pro.setValidTime(project.getValidTime());
        pro.setBidStartTime(bidStartTime);
        if (qualifyFromDateStr != null && !qualifyFromDateStr.isEmpty()) {
            pro.setQualifyFromDate(sdf.parse(qualifyFromDateStr + "-01 00:00:00"));// 合同开始时间
        }
        if (qualifyEndDateStr != null && !qualifyEndDateStr.isEmpty()) {
            pro.setQualifyEndDate(sdf.parse(qualifyEndDateStr + "-01 00:00:00"));// 合同结束时间
        }
        // 投标单位授权代表社保缴纳时间
        String socialSecurityBeginTimeStr = request.getParameter("socialSecurityBeginTimeStr");// 社保开始时间
        String socialSecurityEndTimeStr = request.getParameter("socialSecurityEndTimeStr");// 社保结束时间
        if (socialSecurityBeginTimeStr != null && !socialSecurityBeginTimeStr.isEmpty()) {
            pro.setSocialSecurityBeginTime(sdf.parse(socialSecurityBeginTimeStr + "-01 00:00:00"));// 社保开始时间
        }
        if (socialSecurityEndTimeStr != null && !socialSecurityEndTimeStr.isEmpty()) {
            pro.setSocialSecurityEndTime(sdf.parse(socialSecurityEndTimeStr + "-01 00:00:00"));// 社保结束时间
        }
        // 采购机构网站
        DataSet dataset = dataSetService.get(DataSet.class, Constant.DATASET_ID);
        pro.setProcurementAddr(dataset.getProcurementAddr());
        pro.setProcurementUrl(dataset.getProcurementUrl());
        pro.setOthereRequire(project.getOthereRequire());
        pro.setPerContent(project.getPerContent());
        pro.setContractAmount(project.getContractAmount());
        pro.setNoteText(project.getNoteText());// 前注文本
        pro.setBidType(project.getBidType());
        pro.setIsUnit(project.getIsUnit());
        pro.setCompileTime(new Date());// 编制时间
        pro.setResponseFile(project.getResponseFile());// 响应文件资料
        // 工程类属性
        pro.setTimeLimit(project.getTimeLimit());// 工程工期
        pro.setQualityYears(project.getQualityYears());// 质保期
        pro.setCaluType(project.getCaluType());// 计价方式
        pro.setBiderLevelRequire(project.getBiderLevelRequire());// 竞标人资质等级要求
        pro.setBiderManagerRequire(project.getBiderManagerRequire());// 竞标人项目经理资质等级要求
        pro.setRecommendBrand(project.getRecommendBrand());// 推荐品牌
        pro.setRemind(project.getRemind());// 注意事项
        pro.setParentProjCode(project.getParentProjCode());// 上次开标项目
        pro.setAchievement(project.getAchievement());//业绩
        this.projectInfoService.saveOrUpdate(pro);

        // 生成world
        generateWord(request, pro);
        List<Resources> res = FileResUtil.findResources(project.getId());
        return JSONArray.fromObject(res).toString();
    }

    /**
     * @param resId
     * @return
     * @description 删除文件资源信息
     * @author wwang
     * @date 2016-8-30
     */
    @RequestMapping("/deleteFile")
    @ResponseBody
    public String deleteFile(String resId) {
        // 项目关联清单附件信息(撤销理原因附件)
        Resources res = null;
        res = FileResUtil.getResources(resId);
        if (res != null) {
            this.projectInfoService.remove(res);// 更新
        }
        return Constant.SUCCESS;
    }

    /**
     * @param request
     * @param project
     * @description 生成world方法
     * @author wwang
     * @date 2016-8-29
     */
    private void generateWord(HttpServletRequest request, ProjectInfo project) {
        // 数据处理
        project.setFundFromName(DictUtil.dict("fundFroms", project.getFundFrom()).getName());// 资金来源

        String oldName = project.getName() + "-竞价文件.doc";

        // 判断使用world模板版本
        String worldXmlPath = "trade.xml";// 模板名称
        // 项目类型
        if (Constant.PROJECTCATAGORY_GOODSID.equals(project.getCatagoryId())) {// 货物类
            worldXmlPath = "trade.xml";
        } else if (Constant.PROJECTCATAGORY_SERVICEID.equals(project.getCatagoryId())) {// 服务类
            worldXmlPath = "trade-service.xml";
        } else if (Constant.PROJECTCATAGORY_ENGINEERINGID.equals(project.getCatagoryId())) {// 工程类
            worldXmlPath = "trade-engineering.xml";
        } else if (Constant.PROJECTCATAGORY_PROPERTYID.equals(project.getCatagoryId())) {// 产权类
            // TODO 产权类的竞价文件模板
            worldXmlPath = "trade.xml";
        }

        // 得到文件的相对路径
        // 得到文件的相对路径
        String relativePath = File.separator + "project";
        String uploadPath = request.getSession().getServletContext().getRealPath("file_resource") + relativePath;
        File filePath = new File(uploadPath);
        // 判断文件夹是否存在，如果不存在给与创建出来
        if (!filePath.exists()) {
            filePath.mkdirs();
        }

        // 保存文档到res数据
        List<Resources> resList = FileResUtil.findResources(project.getId());
        // 删除之前的生成的竞价文件
        for (Resources resources : resList) {
            if (resources.getFunctionFlog() == 5) {
                FileResUtil.deleteFile(resources.getId(), request);
            }
        }
        Resources res = new Resources();
        String exeName = ".doc";
        res.setExeName(exeName);
        res.setFilePath(relativePath);
        res.setFileSize(50L);
        res.setOldName(oldName);
        res.setBusinessId(project.getId());
        res.setFunctionFlog(5);// 设置文件功能类型(竞价文件)
        FileResUtil.addFileRes(res); // 保存文件记录

        // 生成文档
        // world保存的真实路径
        String path = uploadPath + "/" + res.getId() + ".doc";
        Map map = new HashMap();
        // 时间
        map.put("maxDate", DateUtils.dataToUpper(new Date()));

        // 项目信息
        map.put("project", project);

        // 前注文本
        List<String> noteText = new ArrayList<String>();
        Collections.addAll(noteText, project.getNoteText().split("@"));
        map.put("noteText", noteText);

        // 合同近几年
        if (project.getQualifyEndDate() != null && project.getQualifyFromDate() != null) {
            int qualifyYear = project.getQualifyEndDate().getYear() - project.getQualifyFromDate().getYear();
            map.put("qualifyYear", qualifyYear == 0 ? qualifyYear + 1 : qualifyYear);// 小于一年按一年算
        }

        List<String> responseFile = new ArrayList<String>();
        Collections.addAll(responseFile, project.getResponseFile().replace("-@", "").split("@"));
        map.put("responseFile", responseFile);

        // 开标前30分钟

        map.put("bidStartTimeBefore", StringUtil.computeDate(project.getBidStartTime(), 0, 0, 0, 0, -30, 0));

        WordHandler world = new WordHandler();
        world.generateWord(path, map, worldXmlPath);// worldXmlPath
    }

    /**
     * 获取交易方式
     *
     * @return
     */
    @RequestMapping("/getTradeType")
    @ResponseBody
    public JSONArray getTradeType() {
        List<Dictionary> natures = DictUtil.dictChildren("tradeType");
        return JSONArray.fromObject(natures);
    }

    /**
     * @description 上传验收报告页面
     * @author shy
     */
    @RequestMapping("/buyer/receivingReport")
    public ModelAndView receivingReprot(HttpSession session, String projectId) {
        ModelAndView mv = new ModelAndView("/proj/buyer/receiving-report");
        mv.addObject("projectId", projectId);
        return mv;
    }

    /**
     * @param projectId
     * @return
     * @description上传验收报
     * @author shy
     */
    @RequestMapping("/uploadReceivingReport")
    @ResponseBody
    public String uploadReceivingReport(HttpSession session, HttpServletRequest request, String projectId,
                                        String budgetMenuData) {
        User user = (User) session.getAttribute("loginUser");
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectId);
        // 上传人信息
        pro.setAuditReportUpTime(new Date());
        pro.setAuditReportUpUserId(user.getId());
        pro.setAuditReportUpUserName(user.getLoginName());
        // 保存文档到res数据
        List<Resources> resList = FileResUtil.findResources(pro.getId());
        // 删除之前的生成的竞价文件
        for (Resources resources : resList) {
            if (resources.getFunctionFlog() == 20) {// 验收报告
                FileResUtil.deleteFile(resources.getId(), request);
            }
        }
        // 项目关联清单附件信息
        if (budgetMenuData != null) {
            String budgetMenuStr[] = budgetMenuData.split(",");
            Resources res = null;
            for (String budgetMenuId : budgetMenuStr) {
                res = FileResUtil.getResources(budgetMenuId);
                if (res != null) {
                    res.setBusinessId(pro.getId());
                    res.setFunctionFlog(20);
                    this.projectInfoService.saveOrUpdate(res);// 更新
                }
            }
        }
        // 设置任务状态
        pro.setStatus(Integer.valueOf(ProjectStatus.WAIT_RECEIVING.toString()));
        this.projectInfoService.saveOrUpdate(pro);
        // 完成任务
        Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
        workflowProcessInstanceService.complete(task.getId(), null);

        return Constant.SUCCESS;
    }

    /**
     * @param projectId
     * @return
     * @description 进入验收审核页面
     * @author shy
     */
    @RequestMapping("/leader/receivingAuditPage")
    @ResponseBody
    public ModelAndView receivingAuditPage(HttpSession session, String projectId) {
        ModelAndView mv = new ModelAndView("/proj/leader/receiving-audit");
        mv.addObject("projectId", projectId);
        return mv;

    }

    /**
     * @param projectId
     * @return
     * @throws ParseException
     * @description 项目负责人验收报告审核
     * @author shy
     */
    @RequestMapping("/leader/receivingAudit")
    @ResponseBody
    public String receivingAudit(HttpSession session, String projectId, String result, String reason)
            throws ParseException {
        User u = (User) session.getAttribute("loginUser");
        Map<String, Object> variables = new HashMap<String, Object>();
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectId);
        Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
        if (result.equals("1")) {
            variables.put("receiverPass", true);
            // System.out.println(Integer.valueOf(ProjectStatus.RECEIVING_SHOWING.toString()));
            pro.setStatus(Integer.valueOf(ProjectStatus.RECEIVING_SHOWING.toString()));// 验收通过，进入验收公示状态
            pro.setReceivingStratTime(new Date());
            // 设置公示时间
            DataSet dataset = dataSetService.get(DataSet.class, Constant.DATASET_ID);
            int publicity = dataset.getReceivingPublicity();// 公示天数
            // String publicityDate = StringUtil.computeDate(new Date(),
            // "00:00:00", publicity+1);//公示时间
            String publicityDate = DateUtils.computeWorkDayDateStr(holidaySetService, new Date(), publicity);// (工作日)公示时间
            variables.put("showReceiverTime", StringUtil.getISODate(publicityDate));
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            pro.setReceivingEndTime(format.parse(publicityDate));
            this.projectInfoService.saveOrUpdate(pro);
            workflowProcessInstanceService.addComment(u.getId(), task.getId(), pro.getWorkflowId(), "receivingReson",
                    reason + "</td><th>审核结果</th><td>审核通过");

        } else if (result.equals("2")) {
            variables.put("receiverPass", false);
            pro.setStatus(Integer.valueOf(ProjectStatus.RECEIVING_UNAUTH.toString()));// 验收不通过，进入验收不同过状态
            this.projectInfoService.saveOrUpdate(pro);
            workflowProcessInstanceService.addComment(u.getId(), task.getId(), pro.getWorkflowId(), "receivingReson",
                    reason + "</td><th>审核结果</th><td>审核不通过");
        }


        workflowProcessInstanceService.complete(task.getId(), variables);
        return Constant.SAVE_SUCCESS;
    }

    /**
     * @param projectId
     * @return
     * @description项目负责人解除合同上传锁定（解锁） @author shy
     */
    @RequestMapping("/leader/unlockContract")
    @ResponseBody
    public String unlockContract(HttpSession session, String projectId) {
        // User u =(User)session.getAttribute("loginUser");
        ProjectInfo pro = projectInfoService.get(ProjectInfo.class, projectId);
        pro.setStatus(Integer.valueOf(ProjectStatus.ALERT.toString()));
        Task task = workflowProcessInstanceService.findTask(pro.getWorkflowId());
        workflowProcessInstanceService.complete(task.getId(), null);
        return Constant.SAVE_SUCCESS;
    }

    /**
     * @description 判断退还履约保证按钮出现状态是否在列举的状态中存在
     * @author shy
     * @date 2016年12月23日
     */
    private boolean excuteDepositButtionByProjectStatus(Integer status) {
        List<Integer> list = new ArrayList<Integer>();
        list.addAll(Arrays.asList(Integer.valueOf(ProjectStatus.WAIT_PROJ_OVER_SURE.toString()), // 结项
                Integer.valueOf(ProjectStatus.PROJ_OVER.toString()), // 项目结束
                Integer.valueOf(ProjectStatus.CANCEL.toString())));// 撤销
        return list.contains(status);
    }


}
